Created
April 27, 2022 22:10
-
-
Save patrickfreitasdev/84d0ed9b3971202a9edb3c566a2d9fd4 to your computer and use it in GitHub Desktop.
This file contains 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
<?php | |
add_action( 'woocommerce_add_to_cart', function ( $cart_item_key, $product_id ) | |
{ | |
//$total = WC()->cart->cart_contents_total; | |
$product_id_trigger = 28; | |
$hustle_module = 'PopUp'; // SlideIn, PopUp | |
$module_id = 188; | |
if( $product_id_trigger == $product_id ): | |
?> | |
<script> | |
function force_module_to_show( _module, _pop_up ){ | |
setTimeout(() => { | |
let leModule = _module; | |
let leId = _pop_up; | |
for ( let i in window.Modules ) { | |
if ( window.Modules[ i ].hasOwnProperty( 'module_id' ) ) { | |
if ( window.Modules[ i ].module_id == leId ) { | |
if(leModule == 'PopUp'){ | |
leModule = new Optin.PopUp( window.Modules[ i ] ); | |
}else if(leModule === 'SlideIn'){ | |
leModule = new Optin.SlideIn( window.Modules[ i ] ); | |
} | |
leModule.showModule(); | |
} | |
} | |
} | |
}, 1000); | |
} | |
let hustle_module = "<?php echo (string) $hustle_module; ?>"; | |
let module_id = <?php echo (string) $module_id; ?>; | |
force_module_to_show( hustle_module, module_id ); | |
</script> | |
<?php endif; | |
}, 99, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment