Created
December 16, 2025 10:57
-
-
Save xlplugins/b628d96487a508e50b744fa7b3eac56c to your computer and use it in GitHub Desktop.
Trigger Slide Cart on Shop Page When Returning from Checkout
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Fkcart_Trigger_Slide_cart_retrun_from_checkout { | |
| public function __construct() { | |
| add_action( 'wp_footer', [ $this, 'js' ] ); | |
| } | |
| public function js() { | |
| if(!is_shop()) { | |
| return; | |
| } | |
| ?> | |
| <script> | |
| // Trigger slide cart on shop page when coming from checkout | |
| jQuery(document).ready(function($) { | |
| // Check if user came from checkout page | |
| var referrer = document.referrer.toLowerCase(); | |
| if (referrer.indexOf('checkout') !== -1) { | |
| setTimeout(function() { | |
| console.log('triggering fkcart_open'); | |
| $(document.body).trigger('fkcart_open'); | |
| }, 500); | |
| } | |
| }); | |
| </script> | |
| <?php | |
| } | |
| } | |
| new Fkcart_Trigger_Slide_cart_retrun_from_checkout(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment