I have a Wordpress website. I am using the Storefront theme for WooCommerce. I have ajax add to cart buttons enabled. When an Add to Cart button is clicked and a product is successfully added to the cart I would like the button to change to a View Cart button (change the text to "View Cart", and link to the cart). If possible I would also like to style the button differently to differentiate it from the standard add to cart button. What would the php code look like?
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- Carriage Return (ASCII chr 13) is missing from tex
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
In Woocommerce by default, when you click on "add to cart" button another button already appears on the right side with "View Cart":
This is already done by a woocommerce jQuery script, that adds after Add to cart button a "View cart" button linked to the cart page…
You can hide the "add to cart" button if you like as when clicked an additional class
"added"
appears in it (see the generated code below):So with CSS you can use
display:none;
on it and only keep "View Cart" …Then is easy to re-style that "view cart" button (linked to the cart page):
So you don't need any code, just some CSS…