Add variable so shipping calculator is shown on first row

Ref: #14461
This commit is contained in:
Mike Jolley 2017-04-17 16:35:33 +01:00
parent d72096e1be
commit cffe326e0e
2 changed files with 11 additions and 9 deletions

View File

@ -202,6 +202,7 @@ function wc_cart_totals_subtotal_html() {
*/
function wc_cart_totals_shipping_html() {
$packages = WC()->shipping->get_packages();
$first = true;
foreach ( $packages as $i => $package ) {
$chosen_method = isset( WC()->session->chosen_shipping_methods[ $i ] ) ? WC()->session->chosen_shipping_methods[ $i ] : '';
@ -215,15 +216,16 @@ function wc_cart_totals_shipping_html() {
}
wc_get_template( 'cart/cart-shipping.php', array(
'package' => $package,
'available_methods' => $package['rates'],
'show_package_details' => sizeof( $packages ) > 1,
'package_details' => implode( ', ', $product_names ),
'package' => $package,
'available_methods' => $package['rates'],
'show_package_details' => sizeof( $packages ) > 1,
'show_shipping_calculator' => $first,
'package_details' => implode( ', ', $product_names ),
// @codingStandardsIgnoreStart
'package_name' => apply_filters( 'woocommerce_shipping_package_name', sprintf( _nx( 'Shipping', 'Shipping %d', ( $i + 1 ), 'shipping packages', 'woocommerce' ), ( $i + 1 ) ), $i, $package ),
'package_name' => apply_filters( 'woocommerce_shipping_package_name', sprintf( _nx( 'Shipping', 'Shipping %d', ( $i + 1 ), 'shipping packages', 'woocommerce' ), ( $i + 1 ) ), $i, $package ),
// @codingStandardsIgnoreEnd
'index' => $i,
'chosen_method' => $chosen_method,
'index' => $i,
'chosen_method' => $chosen_method,
) );
}
}

View File

@ -15,7 +15,7 @@
* @see https://docs.woocommerce.com/document/template-structure/
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.5.0
* @version 3.1.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
@ -54,7 +54,7 @@ if ( ! defined( 'ABSPATH' ) ) {
<?php echo '<p class="woocommerce-shipping-contents"><small>' . esc_html( $package_details ) . '</small></p>'; ?>
<?php endif; ?>
<?php if ( is_cart() && ! $index ) : ?>
<?php if ( ! empty( $show_shipping_calculator ) ) : ?>
<?php woocommerce_shipping_calculator(); ?>
<?php endif; ?>
</td>