xxxxxxxxxx
// Add the product name as data argument to Ajax add to cart buttons
add_filter( "woocommerce_loop_add_to_cart_args", "filter_wc_loop_add_to_cart_args", 20, 2 );
function filter_wc_loop_add_to_cart_args( $args, $product ) {
if ( $product->supports( 'ajax_add_to_cart' ) && $product->is_purchasable() && $product->is_in_stock() ) {
$args['attributes']['data-product_name'] = $product->get_name();
}
return $args;
}
// On Ajax added to cart, shows a lightbox with the product name (and the product id)
add_action( 'wp_footer', 'ajax_added_to_cart_popup_script' );
function ajax_added_to_cart_popup_script() {
?>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@9"></script>
<script type="text/javascript">
jQuery( function($){
// On "added_to_cart" live event
$(document.body).on('added_to_cart', function( a, b, c, d ) {
var prod_id = d.data('product_id'), // Get the product name
prod_qty = d.data('quantity'), // Get the quantity
prod_name = d.data('product_name'); // Get the product name
Swal.fire({
title: '<?php _e("Added to cart!"); ?>',
text: prod_name+' ('+prod_id+')',
showCancelButton: true,
confirmButtonColor: '#000',
cancelButtonColor: '#3085d6',
confirmButtonText: '<?php _e("View-cart"); ?>',
cancelButtonText: '<?php _e("Continue shopping"); ?>'
}).then((result) => {
if (result.value) {
window.location.href = '<?php echo wc_get_cart_url(); ?>';
}
});
});
});
</script>
<?php
}
xxxxxxxxxx
./gradlew wrapper --gradle-version <version>
Example: ./gradlew wrapper --gradle-version 7.2
xxxxxxxxxx
// avoid updating the "distributionUrl" in gradle-wrapper.properties esp for major updates
gradle wrapper --gradle-version=8.5 --distribution-type=all
xxxxxxxxxx
<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
<script>swal("My title", "My description", "success");</script>
xxxxxxxxxx
swal({
title: "Good job!",
text: "You clicked the button!",
icon: "success",
button: "Aww yiss!",
});
xxxxxxxxxx
Swal.fire({
position: 'top-end',
icon: 'success',
title: 'Your work has been saved',
showConfirmButton: false,
timer: 1500
})
xxxxxxxxxx
Swal.fire({
icon: 'error',
title: 'Oops...',
text: 'Something went wrong!',
})
xxxxxxxxxx
Swal.fire({
position: 'top-end',
icon: 'success',
title: 'Your work has been saved',
showConfirmButton: false,
timer: 1500
})
xxxxxxxxxx
Swal.fire({
title: 'Are you sure?',
text: "You won't be able to revert this!",
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Yes, delete it!'
})