Skip to content

Instantly share code, notes, and snippets.

@mihdan
Last active January 14, 2020 08:25
Show Gist options
  • Save mihdan/ab9617bb266fd08ab3537cb1f940a1d0 to your computer and use it in GitHub Desktop.
Save mihdan/ab9617bb266fd08ab3537cb1f940a1d0 to your computer and use it in GitHub Desktop.
Оповещение "Товар добавлен в корзину" для WooCommerce
<?php
/**
* После добавления товара в корзину - показать мадолбное окно
*
* @author mikhail@kobzarev.com
*/
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();">&times;</span>';
$.blockUI({
message: tpl
});
}
});
} );
</script>
<?php
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment