Ich verwende einen benutzerdefinierten Code, der eine Benachrichtigung über den Mindestauftragsbetrag zeigt und die Checkout -Taste blockiert, wenn der Betrag geringer ist. < /p>
/* Minimum Order Notification */
add_action('woocommerce_check_cart_items', 'custom_checkout_min_order_amount');
function custom_checkout_min_order_amount() {
$minimum_amount = 1000;
if (WC()->cart && WC()->cart->subtotal < $minimum_amount) {
wc_add_notice(
sprintf(
'The minimum order is %s. Your order is for %s. You need to add more %s',
wc_price($minimum_amount),
wc_price(WC()->cart->subtotal),
wc_price($minimum_amount - (WC()->cart->subtotal))
),
'error'
);
}
}
remove_action( 'woocommerce_before_cart', 'woocommerce_output_all_notices', 10 );
add_action( 'woocommerce_cart_totals_after_order_total', 'woocommerce_output_all_notices', 10 );
/* Blocking the checkout button */
add_action( 'woocommerce_proceed_to_checkout', 'disable_checkout_button', 1 );
function disable_checkout_button() {
$minimum_amount = 1000;
$total = WC()->cart->cart_contents_total;
if( $total < $minimum_amount ){
remove_action( 'woocommerce_proceed_to_checkout', 'woocommerce_button_proceed_to_checkout', 20 );
echo 'Proceed to checkout';
}
}
< /code>
Ich habe diese Benachrichtigung zum Block "Ihre Bestellung" hinzugefügt. Es gibt ein Problem, wenn die Produktmenge im Karren automatisch aktualisiert wird, und diese Benachrichtigung verschwindet. Ich kann den richtigen Code dafür nicht finden.
Die WooCommerce -Benachrichtigung wird beim Aktualisieren des Wagens gelöscht ⇐ Php
-
- Similar Topics
- Replies
- Views
- Last post