mercredi 24 juillet 2019

jQuery “if this and if that” then run code

I am trying to create a jQuery function that should only run if someone is trying to complete order in WooCommerce order page by selecting wc-completed in dropdown and update order. Basically I want a field to be required before order can be completede. This function should only run if bodyclass = post-type-shop_order.

I tried creating the function but it seems like it's not recognising && - am I doing something wrong here?

$('select#order_status').change(function(){
  if($(this).val() == 'wc-completed') && (!$("body").hasClass("post-type-shop_order")) { 
    $("input#wcam-external-link-0").prop('required',true);
  }
});

Aucun commentaire:

Enregistrer un commentaire