Trigger your custom JS when Extra Options changing

You copy and paste the following snippet to your functions.php on your child theme. The following code will give an alert() to user when an extra option is checked. Adjust the code to your needs add_action("wp_footer", "wpslash_woofood_extra_option_triggers" ); function wpslash_woofood_extra_option_triggers() { ?> <script> jQuery(document).on("change", ".extra-options-accordion input, .extra-options-accordion select", function(){ var current_extra = urldecode(this.value); var obj_current_extra...

November 19, 2020 WPSlash

You copy and paste the following snippet to your functions.php on your child theme.

The following code will give an alert() to user when an extra option is checked.

Adjust the code to your needs

add_action("wp_footer", "wpslash_woofood_extra_option_triggers" ); 
function wpslash_woofood_extra_option_triggers()
{
?>
<script>
jQuery(document).on("change", ".extra-options-accordion input, .extra-options-accordion select", function(){
 						var current_extra =  urldecode(this.value);
 						var obj_current_extra = jQuery.parseJSON(current_extra);

 						var id = obj_current_extra.id;
 						var cat = obj_current_extra.category;
 						var price_html = obj_current_extra.price;
 						var price = obj_current_extra.price_float;
 						var name = obj_current_extra.name;

 						if(this.checked || this.selected)
 						{
 							alert(name+" has Bee checked")
 						}

                    
                     
 });

       function urldecode(str) {
   return decodeURIComponent((str+'').replace(/\+/g, '%20'));
}
</script>
<?php
}

Commission-free ordering

Run restaurant orders on your own WordPress site

FoodMaster adds delivery, pickup, dine-in, POS, and kitchen tools — with zero per-order fees.

Get FoodMaster

Leave a Comment

Your email address will not be published. Required fields are marked *

×

🔥 ONE DAY ONLY OFFER 🔥

Upgrade FoodMaster Today

Normally your license is limited to 1 Website.

Today only, get a LIFETIME Unlimited Websites License for just:
$499

✔ Unlimited Client Websites
✔ Unlimited Personal Projects
✔ Future Updates Included
✔ Save Hundreds on Additional Licenses

Offer Ends In: