Advertisement
hmbashar

Enqueue script for add to cart

Jan 2nd, 2024 (edited)
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. <?php
  2.  
  3. wp_enqueue_script('abcbiz-add-to-cart', AbcBizElementor_Assets . "/js/add-to-cart.js", array('jquery'), false, true);
  4. // Generate the nonce
  5. $abcbiz_add_to_cart_nonce = wp_create_nonce('abcbiz_add_to_cart_nonce');
  6. wp_localize_script('abcbiz-add-to-cart', 'acbbiz_add_to_cart', array(
  7. 'ajax_url' => admin_url('admin-ajax.php'),
  8. 'abcbiz_add_to_cart_nonce' => $abcbiz_add_to_cart_nonce // Add the nonce here
  9. // You can add more data here as needed
  10. ));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement