Issue with ‘Buy in One Click’ button

June 7, 2019 10:42 pm

I’m trying to fix a site that has ‘One Click Buy’ enabled but causing a Javascript error.

It seems that the mwdcp-cocb.js file is loaded on every page when the one click buy options is on. The problem I’m seeing is when the `.mwdcp-cocb-button` is not on the page the call to `` at the top of mwdcp-cocb.js breaks the page.
The workaround I am using to get the site working is checking if `button.length > 0 ` before registering the click handler on the `button` jquery object.

It also looks like the button is only rendered on a `woocommerce_before_single_product` action.
Is loading the script on every page but only using it when the `woocommerce_before_single_product` action is fired the correct behavior?

Published by 5 Comments

5 Replies

Leave a Reply

Your email address will not be published.