我想在点击后重新标记我的添加到购物车按钮并将一件商品添加到购物车,然后再添加一件商品到购物车。
这可能吗?
我有 Child-Theme function.php和第二个转到购物车按钮,这是有效的。
但是我不知道如何在将一件商品添加到购物车后解决这个重新标记的问题(商店只出售一种不同尺寸的商品)。我希望我很清楚。
这是我的代码:
add_filter( 'woocommerce_product_add_to_cart_text',
'customizing_add_to_cart_button_text', 10, 2 );
add_filter( 'woocommerce_product_single_add_to_cart_text',
'customizing_add_to_cart_button_text', 10, 2 );
function customizing_add_to_cart_button_text( $button_text, $product )
{
if ( WC()->cart->get_cart_contents_count() )
return __( 'Add one more to cart', 'woocommerce' );
} else {
return __( 'Add to cart ', 'woocommerce' );
}
Run Code Online (Sandbox Code Playgroud)