// 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
}
<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
<script>swal("My title", "My description", "success");</script><script src="sweetalert2.all.min.js"></script>Swal.fire({
  position: 'top-end',
  icon: 'success',
  title: 'Your work has been saved',
  showConfirmButton: false,
  timer: 1500
})Swal.fire({
  position: 'top-end',
  icon: 'success',
  title: 'Your work has been saved',
  showConfirmButton: false,
  timer: 1500
})swal("Good job!", "You clicked the button!", "success");Swal.fire({
  title: "<i>Title</i>", 
  html: "Testno  sporocilo za objekt: <b>test</b>",  
  confirmButtonText: "V <u>redu</u>", 
  allowOutsideClick: false,
});Swal.fire({
  title: 'هل تريد الاستمرار؟',
  icon: 'question',
  iconHtml: '؟',
  confirmButtonText: 'نعم',
  cancelButtonText: 'لا',
  showCancelButton: true,
  showCloseButton: true
})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!'
})Swal.fire({
  icon: 'error',
  title: 'Oops...',
  text: 'Something went wrong!',
  
})swal({
  title:'thanks'
});

PHP相关代码片段

Laravel macro

what is polymorphic relationship in laravel

php mac change

spatie validate name unique

laravel route subfolder

laravel artisan create command

symfony entity target entity

php two spase remove

mailtrap laravel

php check if var is datetime

bulk taxonomy addition wordpress php

install laravel 10

php datetime format milliseconds

PRAGMA foreign_keys

PHP function to sanitize input prevent XSS

curl php get

php array to stdclass

php curl get parameters array

curl php no response

fpdf allow special characters

stripe payment in php

php filter associative array

Laravel 11 - Production assets issue

php get const properties of a class

http_build_query bearer token

Why do Sessions disappear on refresh? - Laravel

hooks in codeigniter

hard delete laravel

how to view the data in json

laravel pagination with relationship

custom pagination laravel

laravel add new command provider

Laravel Request validation Multiple column Unique

php artisan publish stub

old and edit value laravel blade

how to var_dump in php

how to change php version in ubuntu

temporary change php version to 7.4 ubuntu

terminal in php

get all the variables defined in a php file

is csrf token fixed for a laravel website?

php new datetime

Print loop data in a sigle cell in laravel excel

array to string laravel

joomla get custom fields

time ago function

woocommerce get product by title

what differene insert save and create in laravel

Custom error auth massage laravel

convert letters to numbers php

convert number to letter php

php url rewrite

tcpdf table page break border bottom

laravel View path not found.

php how to check if datetime is valid

php curl and https

ping website is working php

scoped query laravel

php get fractional part of float

laravel scope filter relationship

laravel return empty 200 response

php version required for laravel 11

@selected blade directive

nested back buttons laravel site:stackoverflow.com

Laravel API Resources

set laragon terminal in vscode

pingdom plugin for php

php doc block

php doc block array object

laravel network run

Save dataimage format to save laravel

Illuminate\Queue\MaxAttemptsExceededException

php array print

laravel upi validation

convert int array to string array laravel

get client extension php

vscode default editor in env file laravel

if number in array return true laravel 10

laravel append attribute to model

Change woocommerce Add to Cart text and link