Jump to content

Archived

This topic is now archived and is closed to further replies.

josh1178

Pagelines DMS breaks WooCommerce AJAX add to cart

Recommended Posts

josh1178

It seems that pagelines dms breaks the WooCommerc ajax add to cart on archive pages option. Regardless of whether or not it was set in the Woo Commerce admin settings, it always causes a page load when adding Woo Commerce product to cart. This is on DMS running with no extra plugins on various testing sites. When using the standard Twenty Fourteen theme it works correct and clicking Add To Cart results in AJAX loading of cart. 

 

If this can't be fixed, how can I disable any influence Pagelines has on Woo Commerce product archives and/or remove the Woo Commerce product archive all together and just use a custom Woo grid plugin from a 3rd party?

 

Thanks.

 

EDIT: The problem I'm guessing comes from lib.commerce.php

 

I'd like to remove this somehow if the ajax bit can't be fixed, but I'm not sure how to do it with an override in my child theme.  In that file there is something that says: something about ajax, but it's clearly not working. If you remove lib.commerce.php the standard WOO buttons work just fine. 

// update the cart with ajax

//add_filter('add_to_cart_fragments', 'add_to_cart_fragment');
function add_to_cart_fragment( $fragments ) {
	global $woocommerce;
	ob_start();
	$fragments['a.cart-parent'] = ob_get_clean();
	return $fragments;
}

Share this post


Link to post
Share on other sites
greenfly

Do you have this running on a site we can take a look at please?


The answer to many issues can be found by searching in the forum before posting as someone else  may very well have had the same problem before you have.  Also, reading the documentation can help you gain a good understanding of how everything works. 

 

Please do not send me private messages. Occam's razor - The principle states "Keep things simple!"

Share this post


Link to post
Share on other sites
Simon
the function you have pasted does absolutely nothing as the filter that calls it is commented out in that code.

Share this post


Link to post
Share on other sites
josh1178

Weird, just checked on live site and it seems to be working ok, but it wasn't on my local. Maybe something with MAMP an ajax or a plugin conflic. Will look into it and report back. 

 

Thanks for your time.

Share this post


Link to post
Share on other sites
josh1178

Actually, it is broken. I forgot I was running a test live already where I'd removed the lib.commerce.php which returns Woo Commerce to normal anticipated behavior. 

 

Here is an example of the standard Woo DMS shop.  Click 'add to cart' and you'll see it does a page reload instead of a ajax add to cart. This is with AJAX turned on.  If I remove lib.commerce.php I get the normal Woo Commerce styling back and ajax is working.

 

http://virtualtactile.com/shop/

 

Can anyone confirm this behavior in their shop?

Share this post


Link to post
Share on other sites
Simon

Add to child theme functions.php:

remove_filter('woocommerce_loop_add_to_cart_link', 'pl_commerce_switch_buttons', 10 );

Share this post


Link to post
Share on other sites
josh1178

Thanks Simon, that does the trick of removing the Pagelines button and gets us back in business.

 

Good enough for me, but perhaps this should be listed as a bug somewhere for the devs?

 

Thanks again.

Share this post


Link to post
Share on other sites
josh1178

Simon_P

 

I'm not quite sure what happened or what changed, but I'm finding that the remove filter code you gave doesn't work in my child theme functions file. It does work in the main DMS functions.php file though.

 

I tested the child theme functions.php file to rule out the possibility that something wasn't working in general by using a filter I know is working (remove and it works fine, but the remove_filter function you gave me doesn't.

 

Any idea why it would work in the main functions.php file but not in the childtheme functions.php file? Have you seen this kind of thing happen before?

 

Thanks!

 

 

Share this post


Link to post
Share on other sites
Simon

Doesnt look like you have a child theme active.

Share this post


Link to post
Share on other sites
josh1178

Thanks Simon, but wouldn't my other filters not work too? I can use other filters fine and the theme is set as my WP theme. 

 

I updated to most recent Pagelines DMS, but don't think I did anything else that might have broken it. Strange...

Share this post


Link to post
Share on other sites
josh1178

I just confirmed on test site that it also doesn't work there unless that fuction is put into the main dms functions.php file. If in child theme, it doesn't remove even though other functions are working in child theme.

 

Weird stuff. Is there some other method to remove the lib.commerce.php file entirely? 

Share this post


Link to post
Share on other sites
Danny

As far as I can tell, you're using some weird kind of grid plugin, called Essential Grid. Therefore, your issue isn't with a core DMS section nor WooCommerce, so you will need to do contact the developer of the plugin you're using for assistance.


Please search our forums, before posting!

Share this post


Link to post
Share on other sites
josh1178

Sorry Danny, I recently changed that test page to show the grid plugin only, so it's not quite relevant. 

 

Ajax is indeed not working with the DMS add to cart buttons supplied by Pagelines and Simon's fix worked to get me back standard button behavior.

 

However, the problem I'm having now is that the filter function Simon gave me only works when I input the code into the DMS functions.php, but not the skeleton child theme functions.php.

 

Is there some way to remove lib.commerce.php entirely if I can't get this function to work?

 

Share this post


Link to post
Share on other sites
Danny

I will speak to Simon, as I too am having the same issue.


Please search our forums, before posting!

Share this post


Link to post
Share on other sites
Simon

Try this

add_action( 'after_setup_theme', 'my_fixed_woo' );
function my_fixed_woo() {
    remove_filter('woocommerce_loop_add_to_cart_link', 'pl_commerce_switch_buttons', 10 );
}

Share this post


Link to post
Share on other sites
josh1178

Thanks guys, that seems to work when using the standard function.php in child theme.

;)

Share this post


Link to post
Share on other sites
Danny

Thanks for informing us the issue has been resolved.


Please search our forums, before posting!

Share this post


Link to post
Share on other sites

  • Similar Content

    • Lisa Haran
      By Lisa Haran+
      Hi 
      I have a map here http://www.iloveoffset.com/maps/
      I want to add several pointer locations to the map, but when I do they do not appear.
      On this map there are 2 pointer locations and as you can there is only one visible.
      Earlier today I added 7 and could only see 4 so there is something odd going on.
      My theme is up to date
    • clj182
      By clj182+
      Hello,
      I've been having trouble unlocking the template section for past couple of weeks. When I try clicking nothing happens. 
      I've deleted my custom css and removed plugins. Im down to having only the following plugins:
      Akismet
      Contact Form 7
      DMS Professional Tools
      Pagelines Updater
      WooCommerce
      It was working fine before i have no idea what's going on with it.
    • flourishdesignstudio
      By flourishdesignstudio+
      My DMS 2 site http://www.heart-stone.com/ will not save any new custom css... I can still edit templates and publish those but any custom css that I enter never saves.
      All WP files, themes, and plugins are up to date. 
      Any thought about what might be causing this?
    • flourishdesignstudio
      By flourishdesignstudio+
      Is there a way to edit the custom CSS via FTP? I know I can edit the custom code in the Chrome editor but is there a file path I can use to find and edit the CSS directly from our FTP?
      Thanks in advance for the help!
    • nizami
      By nizami+
      Using navbar section with correctly configured WP menu to display main navigation at https://elenaangel.com. 
      All fine in desktop viewport. Menu displays twice in hamburger mode. How to fix this please? 

×