Always starts open inside table
-
Hi there,
I am using your plugin insed a product custom field which I am displaying in Woocommerce cart and checkout table.
Even though I have set the collapsible to be closed by default, it always starts open inside both the cart and checkout table. Could you please let me know how to have it closed by default? You can check the behaviour here, please put the product into the cart and go to cart and checkout page. Thank you very much!
-
Hello.
The issue seems to be that the each of the items in the shopping cart are loaded dynamically after the page load. You will have to reach out to your theme author and ask if they provide a callback on after the checkout items have successfully loaded so other functions can be triggered.
Refer them to this thread if you like.
Hi,
I have asked the theme author and he said this has absolutely nothing to do with the theme, it’s a woocommerce and collapseomatic issue.So is there a way to have the collapsible display correctly inside the tables? I tried the “Ultimate Shortcodes” plugin which also has ana ccordion shortcode and this one worked, but I can’t use that plugin due to ther conflicts, so I would love to use yours.
So is there a way to have the collapsible display correctly inside the tables?
The expand element is displaying correctly, it’s just that the expand element is being loaded dynamically, after the initial page load scripts have already fired.
If it’s not something related to the theme, then it will be a very easy google search on what callbacks woocommerce offers…
…yes, first hit.You do know how to add Javascript/jQuery to your child-theme, correct? Good.
Here is the callback that needs to hooked into:jQuery( document ).on( 'updated_checkout', function() { collapse_init(); } );-
This reply was modified 6 years, 12 months ago by
twinpictures.
Hi,
thanks for your reply.
Sorry I a not an expert or professional programmer in any way – that’s why I came here for support.
I added the script you mentioned into my child theme, and while the collapsible now is closed by default, it is added twice after the product name.it is added twice after the product name
We are no longer seeing the expand element in the cart. Has this been moved?
How exactly did you add the script to your child theme?Sorry I a not an expert or professional programmer in any way – that’s why I came here for support.
We do what we can to support our free plugins, however this issue is more to do how woocommerce is loading the content of the checkout list. If you require a more professional assistance, we do offer a very high level of personal support with our pro plugin collapse-pro-matic.
Hi,
sorry, I had tried it on a different site.
I have added the code your provided with the “headers and footers” plugin, but oviuosly I am doing something wrong since the code is showing up in the footer, and the collapsible is not affected in any way.Your child-theme should have a functions.php file.
Add this to that:add_action('wp_footer', 'my_footer_javascript'); function my_footer_javascript() { ?> <script> jQuery( document ).on( 'updated_checkout', function() { collapse_init(); } ); </script> <?php }Additional Reading:
https://www.wpbeginner.com/wp-tutorials/how-to-easily-add-javascript-in-wordpress-pages-or-posts/
https://codex.ww.wp.xz.cn/Plugin_API/Action_Reference/wp_footerThank you very much. I did, and the problem still exists – accordion open by default.
Well this is fun.
ok, change the js to the following:
jQuery( document ).on( 'init_checkout', function() { console.log('hey dude, init checkout has ben called!'); collapse_init(); } );We have changed the callback to: init_checkout and added a message that will at least let us know if and when the callback is fired.
Okay I did!
ok, again, wrong callback…
kind of like playing battleship.
Next up: updated_wc_divjQuery( document ).on( 'updated_wc_div', function() { console.log('hey dude, updated_wc_div has ben called!'); collapse_init(); } );Okay, done!
ok, one last try:
jQuery( document ).ready(function() { console.log('hey dude, page is ready...'); collapse_init(); } );okay,done.
so crazy… so yeah, it’s triggering, but nothing is happening… let’s try and put a timer on that:
jQuery( document ).ready(function() { console.log('thinking about maybe triggering some things...'); setTimeout(function() { console.log('...yeah, why not.'); collapse_init(); }, 1000); } );Fret not, we’ll figure it out.
-
This reply was modified 6 years, 12 months ago by
The topic ‘Always starts open inside table’ is closed to new replies.