Skip Navigation

[Resolved] Which shortcode for WooCommerce Plugin Default Templates add to cart button?

This support ticket is created 5 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Tagged: 

This topic contains 25 replies, has 3 voices.

Last updated by StanleyT8485 5 years, 10 months ago.

Assisted by: Beda.

Author
Posts
#1195219

Where can I copy the HTML markup generated from the default template?

I opened the source code and copied the button directly.

<form class="cart" action="<em><u>hidden link</u></em>" method="get" enctype="multipart/form-data">
<a href="/product/a-frame-signs/?personalize=true" name="add-to-cart" value="592" class="single_add_to_cart_button button alt">Personalize</a>
</form>

The button changes to "Personalize". However, it doesn't work / it doesn't bring up the editor. There must be a script missing or something.

#1195481

Well the idea is that you replace this form markup in the Content Template with the wpv-woo-buy-or-select shortcode, or the wpv-woo-buy-options shortcode. Then the proper scripts should be enqueued for the custom add-to-cart button.

#1195675

I don't quite understand.

I added this into the content template and I also tried the [wpv-woo-buy-or-select] and [wpv-woo-buy-options] and none of those option works.

<form class="cart" action="[wpv-post-slug]" method="get"  enctype="multipart/form-data">
<a href="[wpv-post-slug]?personalize=true" name="add-to-cart" value="[wpv-post-id]" class="single_add_to_cart_button button alt">Personalize</a>
</form>

What am I doing wrong? Would you be able to create a test page for what you mean?

#1195690

I mean do not include the form tag in your Content Template code. Include the wpv-woo-buy-or-select shortcode, or the wpv-woo-buy-options shortcode, instead of the form tag. Those shortcodes will generate the proper form code for you automatically, and they will also enqueue the necessary scripts.

#1195691

I tried both [wpv-woo-buy-or-select] and [wpv-woo-buy-options] and it doesn't bring up the editor when you click the add to cart button.

When you switch back to the default template, clicking the add to cart button brings up the editor.

#1196213

Okay I understand more completely now. The Personalize button displays as expected, that's not the problem. It's when the page reloads with the ?personalize=true URL parameter, the personalization editor does not appear as expected. I need to escalate this to my 2nd tier support team for further investigation. It seems to be a compatibility issue, but I'll know more when I get some feedback from them. Stand by and I'll update you when I have something to share.

#1197313

Okay I have a status update, my 2nd tier team spent a while trying to get through this one as well, but on our local environments there are simply too many JavaScript errors to make sense of what's happening here. Not sure if that's because it's a prototype (version 0.0.1) or because our setup is incorrect. If we add a shortcode to the Content Template, it seems to work more like expected:

[wpv-woo-product-image enable_third_party_filters="yes"]

However, with so many JS errors locally it's hard to tell. Can you try adding this shortcode to your Content Template?

I'm assigning this ticket to Beda so he can respond to your followup.

#1197602

Hi,

I have added that shortcode.

As a side question, why do you think there are so many JS errors? How do we get rid of them?

#1197657

Hello, this is Beda, and I have a few updates related to this issue.

1. This Plugin seems to be in an initial state of development and is not working error free on a clean WordPress install.

- When you install the plugin with WooCommerce and WordPress only, you get several issues, ranging from JS errors, to "Please wait" placeholders that never disappear to show the iFrames expected.
- It has version 0.0.1 which seems to confirm that it is the first release. Eventually the developers want to know about this errors in their plugin, however, I cannot find any documentation (related to the plugin and its usage on WordPress) and also there is no support forum it seems. I suggest testing this plugin on your end on a clean WordPress install and let the author know the issues you will encounter (To see the errors you just need to open the browser console and look at the red errors when editing a product or visiting a product in personalization mode, this, without having Toolset installed)

2. The Plugin uses a template to show the iFrame that is used to customize the product (personalize.php) and loads this template in a native WooCommerce Hook, woocommerce_before_single_product_summary.
We support third-party filters for this hook when you display the Product Image (which is hooked on woocommerce_before_single_product_summary).
The plugin also hooks the button to personalise on woocommerce_single_product_summary, but we do not load woocommerce_single_product_summary.
You could create a custom shortcode and return it, so to use that in the Content Template:

function add_wc_actions() {
	$out =	do_action( 'woocommerce_single_product_summary' );
	return $out;
}
add_shortcode('add-wc-custom-hooks', 'add_wc_actions');

In a content template you can add The Product Image itself (so to get the iFrame working) with [wpv-woo-product-image enable_third_party_filters="yes"] and then the 3rd party iFrames load (with the same errors as on a clean WordPress install of course, however it loads, which is not the case if you omit the product image).
You can either add a custom HTML link to the personalizer as you did already or use the above shortcode, where the 3rd party hooks in, however designing with CT's will become more depending on other filters applied here.

3. Please let me know if this would be a possible solution for you. The problem here is that to allow utmost customizability by Toolset Content Templates, we load the title and the content (which is replaced by the template) only, if you use Content Templates, and add the woocommerce_before_main_content and woocommerce_after_main_content actions around it.

Please let me know if this helps, and I suggest informing the other plugins author about the mentioned errors.

#1202799

Hey Beda,

Thanks for your detailed reply. I have brought this up to the developer and they will fix the compatibility issues.

Stan

#1202800

My issue is resolved now. Thank you!