• Resolved Delve

    (@singhwise)


    I’m trying to add some javascript that will hide a div if it contains a particular type of text. In thise case if the price is shown as £0.00 I want to hide the div using javascript.

    I’ve noticed this works for any custom div’s that I create, but it fails to work for any wp-shopify divs.

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author andrewmrobbins

    (@andrewmrobbins)

    @singhwise Hey there,

    It might be due to the plugin’s loading cycle. If you’re running custom JavaScript targeting the plugin, you’ll need to place it within the after.cart.ready hook, like this:

    
    wp.hooks.addAction('after.cart.ready', 'wpshopify', function (cartState) {
        jQuery('.wps-product-individual-price[data-price="0"]').closest('.wps-item').hide();
    });
    

    https://docs.wpshop.io/#/js/actions/cart?id=aftercartready

    Does this help?

    Thread Starter Delve

    (@singhwise)

    I’m having a problem getting that script to load up. When viewing source I can see the hook which pulls in the product SKU but not this hook. Even though it’s been added into the same file.

    Not sure what’s going on here..

    • This reply was modified 3 years, 4 months ago by Delve.
    Plugin Author andrewmrobbins

    (@andrewmrobbins)

    This has been fixed, but for anyone else seeing this thread, try adding this JavaScript to your WP theme:

    
    `wp.hooks.addAction('after.cart.ready', 'wpshopify', function (cartState) {
    
        var zeroPriceElements = jQuery('.wps-product-individual-price[data-price="0"]');
    
        zeroPriceElements.parent().hide();
    
    });
    
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Trying to customise using javascript’ is closed to new replies.