[Resolved] Customising 'add to cart' button links
Great little plugin – kind of does about half of what I was trying to achieve, so just wondering if it could be extended to finish the job!
Here’s my thoughts: Simple products can be added to the shopping cart directly from the product list page as there is no need for a customer to necessarily go to the single products page. Fine!
However, more complicated products (e.g. those with variations) need the customer to go to the main single product page to select their desired options. So you don’t want an ‘add to cart’ button for these products, but instead you want a ‘Select options’ button which takes them to the product page to do just that. Now your plugin currently solves part 1 (renaming the button), but this is a little pointless unless you can change the button link from the standard ‘add to cart’ to a link to the product page.
So is this possible do you think, please?
Also, I am using the ‘WooCommerce Product Add-Ons’ plugin to give the customer the option or selecting from various alternatives, see here:
In your plugin, I can set different ‘add to cart’ button texts for simple, variations, grouped and external products, but there is no way of changing the text for products with add-ons created with the product (they currently just fall under the simple products category).
Could you add this extra class of products please to enable compatibility between these two great plugins?
Thanks and regards, James
Thanks for trying the plugin. It’s really designed to make simple customizations, so it might be difficult to adapt it to your specific needs. What you’re asking can be accomplished through using a conditional filter that checks what type of product it is before modifying the add to cart button text.
As for the product add-on, it’s probably worth submitting a ticket at http://support.woothemes.com to request a feature addition for the ability to change the add to cart button just for products that have “add-ons” enabled.
Hope this helps!
Thanks for getting back to me. Just wanted to clarify a couple of points with you please:
With regards to changing the ‘add to cart’ button link for more complicated products (ie those with options of some sort), you mentioned this could be achieved by using a conditional filter to determine what sort of product it is before modifying the button. Does WP already have different setting for the button label for the different product types, or is this something your plugin adds? I was assuming that the plugin was using a conditional filter already to change the button text, but you seem to be saying that these alternative ‘add to cart’ button labels are already built into WP?
Yes, when viewing products on the the shop loop (not on a single product page), there are specific filters that control the Add to Cart button text depending on what type of product it is — see this template for the full list: https://github.com/woothemes/woocommerce/blob/master/templates/loop/add-to-cart.php
For the single product page, there is a single filter (see each product type template here : https://github.com/woothemes/woocommerce/tree/master/templates/single-product/add-to-cart) that controls the Add to Cart button text. There is a global
$productobject that you can use inside that filter to check what type of product it is and adjust the the text accordingly. Hope this helps!
Thanks Max. Sounds like it might be a bit beyond my current coding abilities at this stage, but at east I’m better prepared for knowing exactly what it actually is I’m trying to do! Who know, the necessary code may already be out there for me to find on a forum somewhere…..
I’ve opened a ticket with WooThemes and I’ll let you know if anything comes of that that might be of relevance for your plugin.
James what did you figure out from the ticket?
Is this what you’re trying to achieve: http://wordpress.org/support/topic/woocommerce-displaying-product-variation-inside-loop
Hi Chirag740. Long time ago now, hard to remember exactly what conclusions / answers I came up with. But I think most of these have now been resolved by updates to WooCommerce and the plugin. From memory, it was more an issue with the ‘Product Add-ons’ plugin than with this plugin though.
- The topic ‘[Resolved] Customising 'add to cart' button links’ is closed to new replies.