Answer the question
In order to leave comments, you need to log in
How to update posts on Woocommerce cart page?
Hi everyone, I'm having a problem updating the cart page.
The store sells products that come in boxes, and there is a need for customers to form their own "boxes" with various products.
A rough description and implementation is here.
The question is -
For example, we added a minimum amount of purchases in the store and decided to show this in a message on the cart page if the amount is not reached, so that the person could not go to the calculation page.
wc_add_notice( sprintf( __( "Минимальная сумма заказа %s $", 'woocommerce' ), $min_amount ), 'error' );
add_filter( 'woocommerce_update_cart_action_cart_updated', 'woocommerce_check_cart_quantities_for_class' , 5, 1);
function woocommerce_check_cart_quantities_for_class() {
global $woocommerce;
$items = $woocommerce->cart->get_cart();
$subtotal = WC()->cart->get_cart_subtotal();// выводиться в виде "$0.936,00" -> 936$
$min_amount = "$0.050,00";// 50$
if($subtotal < $min_amount){
wc_add_notice( sprintf( __( "Минимальная сумма заказа %s $", 'woocommerce' ), $min_amount ), 'error' );
}else{
wc_add_notice( sprintf( __( "Теперь вы можете переходить на страницу расчета", 'woocommerce' ), ), 'notice' );
}
}
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