Last active
January 14, 2020 08:25
-
-
Save mihdan/ab9617bb266fd08ab3537cb1f940a1d0 to your computer and use it in GitHub Desktop.
Оповещение "Товар добавлен в корзину" для WooCommerce
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
<?php | |
/** | |
* После добавления товара в корзину - показать мадолбное окно | |
* | |
* @author [email protected] | |
*/ | |
add_action( | |
'wp_footer', | |
function() { | |
?> | |
<script> | |
jQuery( function( $ ) { | |
$( document.body ).on( 'adding_to_cart', function( a, b ) { | |
var $btn = $( b[0] ); | |
var product_title = $btn.data( 'product_title' ); | |
if ( product_title ) { | |
var tpl = ''; | |
tpl += '<h1>Товар добавлен в корзину</h1>'; | |
tpl += '<p>' + product_title + '</p>'; | |
tpl += '<div>'; | |
tpl += '<a class="btn btn-default" onclick="jQuery.unblockUI();">Продолжить покупки</a>'; | |
tpl += '<a href="/shop/cart/" class="btn btn-primary">Оформить заказ</a>'; | |
tpl += '</div>'; | |
tpl += '<span class="close" onclick="jQuery.unblockUI();">×</span>'; | |
$.blockUI({ | |
message: tpl | |
}); | |
} | |
}); | |
} ); | |
</script> | |
<?php | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment