Im Moment versuche ich es so zu bekommen, dass, wenn jemand auf die Produktseite meiner Seite kommt, sein Warenkorb automatisch geleert wird.Woocommerce Produkt Addon - Warenkorb leer beim gehen zur Produktseite
Ich benutze ein Woocommerce-Produkt-Addon namens "Produkt & Checkout-Optionen für WooCommerce", die mir Radiobuttons/Checkboxen für meine Produkte verwenden kann, ich weiß nicht, ob das Code ändern wird.
Ich habe PHP-Code versucht, wie dies aber es hat nicht funktioniert:
add_filter('woocommerce_add_to_cart_validation', 'only_one_in_cart' , 10, 1);
function only_one_in_cart($cart_item_data) {
global $woocommerce;
$woocommerce->cart->empty_cart();
unset($cart_item_data['product_meta']);
return true;
}
Hat es funktioniert? Wähle meine Antwort aus, wenn es funktioniert – Skatox