G
G
greedy_wizard2021-02-03 17:44:01
WordPress
greedy_wizard, 2021-02-03 17:44:01

How to add shipping block in WooCommerce?

Help to embed a delivery block between fields 601ab6e898863059103773.pngFields are output using

<div class="woocommerce-billing-fields__field-wrapper">
    <?php
    $fields = $checkout->get_checkout_fields( 'billing' );

    foreach ( $fields as $key => $field ) {
        woocommerce_form_field( $key, $field, $checkout->get_value( $key ) );
        
    }
    ?>
</div>

and the shipping code
<?php if ( WC()->cart->needs_shipping() && WC()->cart->show_shipping() ) : ?>

<?php do_action( 'woocommerce_cart_totals_before_shipping' ); ?>

<?php 
wc_cart_totals_shipping_html(); 
?>

<?php do_action( 'woocommerce_cart_totals_after_shipping' ); ?>

<?php elseif ( WC()->cart->needs_shipping() && 'yes' === get_option( 'woocommerce_enable_shipping_calc' ) ) : ?>

<tr class="shipping">
    <th><?php esc_html_e( 'Shipping', 'woocommerce' ); ?></th>
    <td data-title="<?php esc_attr_e( 'Shipping', 'woocommerce' ); ?>"><?php woocommerce_shipping_calculator(); ?></td>
</tr>

<?php endif; ?>

how to put this block in between the required fields?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
trenton, 2021-02-05
@trenton

Is it or isn't it? And then I also decide the same.
https://wpruse.ru/woocommerce/hiding-fields-on-cho...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question