Answer the question
In order to leave comments, you need to log in
How to change the structure of the checkout page on woocommerce?
On the checkout page, you need to change the html structure of the delivery method selection block.
By default, the block has the following html table structure:
<table>
<tr>
<th>Доставка</th>
<td>
<ul>
<li>Способ 1</li>
<li>Способ 2</li>
<li>Способ 3</li>
<li>Способ 4</li>
</ul>
</td>
</tr>
</table>
wc_cart_totals_shipping_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 ] : '';
$product_names = array();
if ( count( $packages ) > 1 ) {
foreach ( $package['contents'] as $item_id => $values ) {
$product_names[ $item_id ] = $values['data']->get_name() . ' ×' . $values['quantity'];
}
$product_names = apply_filters( 'woocommerce_shipping_package_details_array', $product_names, $package );
}
wc_get_template(
'cart/cart-shipping.php', array(
'package' => $package,
'available_methods' => $package['rates'],
'show_package_details' => count( $packages ) > 1,
'show_shipping_calculator' => is_cart() && $first,
'package_details' => implode( ', ', $product_names ),
/* translators: %d: shipping package number */
'package_name' => apply_filters( 'woocommerce_shipping_package_name', ( ( $i + 1 ) > 1 ) ? sprintf( _x( 'Shipping %d', 'shipping packages', 'woocommerce' ), ( $i + 1 ) ) : _x( 'Shipping', 'shipping package', 'woocommerce' ), $i, $package ),
'index' => $i,
'chosen_method' => $chosen_method,
)
);
$first = false;
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question