Pregunta

Using woocommerce, I need a way to remove the subtotal in the checkout if there is only 1 product in the cart.

Anyone know what the best way to do this and how?

No hay solución correcta

Otros consejos

You could always put a if statement around, cart->get_total(); ?>, in you cart.php file. Not sure if it's cart php but something like that.

Just be aware. After an update this will be gone. So please create this in your child theme.

Something like:

$something = echo $woocommerce->cart->get_total();
global $woocommerce;

if ( sizeof( $woocommerce->cart->cart_contents) == 1 ) :
$somthing = '';
endif;


<strong>$somthing</strong>

You can override, 'review-order.php' template file located in, 'checkout' directory.

You can add following condition above 'cart-subtotal' class,

<?php if(WC()->cart->cart_contents_count != 1) : ?>
  <tr class="cart-subtotal">
    <th><?php _e( 'Subtotal', 'woocommerce' ); ?></th>
    <td><?php wc_cart_totals_subtotal_html(); ?></td>
  </tr>
<?php endif; ?>
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top