You can’t edit this product
-
Hi,
I’m working on a webshop for secondhand books. I have an issue with an error message woocommerce sends out when you press the add to cart button a second time.
The situation:
My webshop has secondhand books. Every product has a stock of one by default and that’s fine.The problem:
Whenever you add a product to your cart, everything goes well (except for some design flaws). When you click it again, it goes to the single product page and in the header it shows an error message “You can’t add this product to your cart — we have one in stock and you already have on in your cart – View Cart”Wanted behaviour:
I would like to know how I can change where this message pops up. I don’t want it on the product page, I want the message on the shop page. Because that redirect is quite weird as you can’t order the product anyway. So I don’t want that redirect.
Also would I like to change the look of that error message.It are probably some basic questions, but I’m not that gifted concerning woocommerce. I hope someone can help me.
Thank you in advance.
The page I need help with: [log in to see the link]
-
Hi @dennis1992
I’d be glad to help!
The text cannot be changed using the core WooCommerce options, however it can be edited using some custom coding.
I’ve found this post from Stack Overflow with a snippet you can add to your theme’s functions.php file:
https://stackoverflow.com/questions/53796760/change-add-to-cart-stock-error-notice-in-woocommerce
Do note that we have not tested that code ourselves, it would be best to create a staging environment and test this first, you can use this free plugin to clone your site into a testing version https://wordpress.org/plugins/wp-staging/
The error should be displayed on the product page only, if you wish for this to show on a different location, it would require additional custom code.
If you require additional assistance with custom coding, I’d recommend reaching out to our team of experts here https://woocommerce.com/experts/
Alright! Thank you! Is there also a way to edit the design? Or should that be done with code as well?
Hi @dennis1992
Some design modification can done with custom CSS: https://woocommerce.com/document/customizing-woocommerce-best-practices/
If you’d like to learn about CSS, I highly recommend using the free tutorials at w3schools. Here, you can find the basics of selectors (how to target the right element on the page), and properties (how to change the element on the page).
The topic ‘You can’t edit this product’ is closed to new replies.