Home › Forums › WoodMart support forum › Already added to Cart
Already added to Cart
- This topic has 7 replies, 3 voices, and was last updated 4 years, 10 months ago by
Artem Temos.
-
AuthorPosts
-
June 28, 2020 at 7:10 pm #207078
afarahaniParticipantHi,
It seems the theme lacks the feature that when a single product is already added to the cart, it tells the visitor it is already in the cart by changing the icon or button text and deactivating the “Ad to Cart” button. Instead, it allows clicking on the “add to cart” button if in the shop and takes the user to product page (for single product) and then shows a message that this is already in the cart.Same situation with product page “add to cart” button. When the product is added to the cart, still doesnt know the product is already selected because the button still allows selecting the prodcut.
Can you please provide a fix for this?
June 28, 2020 at 7:50 pm #207097
afarahaniParticipantTO meet you in the middle, I added the following code to change the text when the product is already in the cart. Please let me have a code to deactivate click function on the cart button in shop and product page when it is already in the cart.
add_filter( 'woocommerce_product_single_add_to_cart_text', 'bbloomer_custom_add_cart_button_single_product' ); function bbloomer_custom_add_cart_button_single_product( $label ) { foreach( WC()->cart->get_cart() as $cart_item_key => $values ) { $product = $values['data']; if( get_the_ID() == $product->get_id() ) { $label = __('Already in your list', 'woocommerce'); } } return $label; } // Part 2 // Edit Loop Pages Add to Cart add_filter( 'woocommerce_product_add_to_cart_text', 'bbloomer_custom_add_cart_button_loop', 99, 2 ); function bbloomer_custom_add_cart_button_loop( $label, $product ) { if ( $product->get_type() == 'simple' && $product->is_purchasable() && $product->is_in_stock() ) { foreach( WC()->cart->get_cart() as $cart_item_key => $values ) { $_product = $values['data']; if( get_the_ID() == $_product->get_id() ) { $label = __('Already in your list', 'woocommerce'); } } } return $label; }
June 29, 2020 at 7:15 am #207170
Eric WatsonParticipantHello,
Could you please check how it works with some default WordPress themes like TwentyTwenty or WooCommerce Storefront to understand is it our theme issue or not?
Regards
June 29, 2020 at 6:14 pm #207359
afarahaniParticipantIt works perfectly fine with Woodmart, but I have not tested it with any other theme. The only thing that is missing is to dissable the click and hover functions of button when the individual item (for exmple for downloadable prodcut) is already in the cart.
June 29, 2020 at 6:14 pm #207360
afarahaniParticipantWould you help with that part?
June 30, 2020 at 7:38 am #207467
Artem TemosKeymasterHello,
Sorry, but such additional code customizations are out of our theme support scope.
Thank you for understanding.
Kind Regards
June 30, 2020 at 8:13 am #207479
afarahaniParticipantYeah! I am sorry too that such feature is also not already part of the theme.
June 30, 2020 at 8:19 am #207482
Artem TemosKeymasterNo problem, contact us if you will have any questions.
-
AuthorPosts
The topic ‘Already added to Cart’ is closed to new replies.
- You must be logged in to create new topics. Login / Register