Issue with ‘Buy in One Click’ button

June 7, 2019 10:42 pm

Hello,
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 `button.live` 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 4 Comments

4 Replies

Leave a Reply

Your email address will not be published.