Advertisement
yesamarcos

Fix Out of Stock in configurable product

Jul 18th, 2017
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 1.67 KB | None | 0 0
  1.     /* Automatic hide and select variation for mug */
  2.     $('#attribute183 option[value="50"]').attr('selected', 'selected');
  3.     $("#attribute183").removeClass('required-entry').css("display", "none");
  4.  
  5.     /* On change function to show and hide variations in chosse item */
  6.     $("#attribute182").on('change', function(event) {
  7.         /* Items to show variation */
  8.         var arr = ["camiseta", "blusinha"];
  9.         /* Get item selected to compare with arr */
  10.         var info = $("#attribute182 option:selected").data("label");
  11.  
  12.         /* if info in arr */
  13.         if($.inArray(info, arr) != -1){
  14.             /* Disable mug variation */
  15.             $('#attribute183 option[value="50"]').removeAttr('selected').attr("disabled", "disabled");
  16.             /* Force required to variations */
  17.             $("#attribute183").addClass('required-entry').css("display", "block");
  18.  
  19.         } else {
  20.             /* Enable mug variation and auto-select */
  21.             $('#attribute183 option[value="50"]').removeAttr("disabled").attr('selected', 'selected');
  22.             /* Remove force required to variations */
  23.             $("#attribute183").removeClass('required-entry').css("display", "none");
  24.         }
  25.         /* If on change action in first select, remove disabled in all options */
  26.         $("#attribute182 option, #attribute183 option").each(function() {
  27.             $(this).removeAttr('disabled');
  28.         });        
  29.     });
  30.      /* If on change action in second select, remove disabled in all options */
  31.     $("#attribute183").on('change', function(event) {
  32.         $("#attribute182 option").each(function() {
  33.             $(this).removeAttr('disabled');
  34.         });
  35.     });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement