Using 0 as default value if some loop parameters are not defined
This commit is contained in:
@@ -19,7 +19,7 @@
|
|||||||
<label for="coupon-products-id">{intl l="Applies to attribute values :"}</label>
|
<label for="coupon-products-id">{intl l="Applies to attribute values :"}</label>
|
||||||
|
|
||||||
<select required multiple size="10" class="form-control" id="coupon-attributeAvs-id" name="{$attribute_av_field_name}[]">
|
<select required multiple size="10" class="form-control" id="coupon-attributeAvs-id" name="{$attribute_av_field_name}[]">
|
||||||
{loop type="attribute_availability" attribute=$attribute_value name="list-of-attribute_avs" backend_context="1"}
|
{loop type="attribute_availability" attribute=$attribute_value|default:0 name="list-of-attribute_avs" backend_context="1"}
|
||||||
<option value="{$ID}" {if in_array($ID, $attribute_av_values)}selected="selected"{/if}>{$TITLE}</option>
|
<option value="{$ID}" {if in_array($ID, $attribute_av_values)}selected="selected"{/if}>{$TITLE}</option>
|
||||||
{/loop}
|
{/loop}
|
||||||
</select>
|
</select>
|
||||||
@@ -59,5 +59,7 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
|
||||||
|
{block name="javascript-init"}{/block}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -12,3 +12,9 @@
|
|||||||
|
|
||||||
<span class="label-help-block">{intl l='Use Ctrl+click to select (or deselect) more that one category'}</span>
|
<span class="label-help-block">{intl l='Use Ctrl+click to select (or deselect) more that one category'}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function couponInputFormSetup() {
|
||||||
|
{block name="javascript-init"}{/block}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|||||||
@@ -19,8 +19,8 @@
|
|||||||
<label for="coupon-products-id">{intl l="Applies to products :"}</label>
|
<label for="coupon-products-id">{intl l="Applies to products :"}</label>
|
||||||
|
|
||||||
<select required multiple size="10" class="form-control" id="coupon-products-id" name="{$products_field_name}[]">
|
<select required multiple size="10" class="form-control" id="coupon-products-id" name="{$products_field_name}[]">
|
||||||
{loop type="product" category=$category_id_value name="list-of-products" backend_context="1"}
|
{loop type="product" category=$category_id_value|default:0 name="list-of-products" backend_context="1"}
|
||||||
<option style="padding-left: {$LEVEL * 10}px" value="{$ID}" {if in_array($ID, $products_values)}selected="selected"{/if}>{$TITLE}</option>
|
<option value="{$ID}" {if in_array($ID, $products_values)}selected="selected"{/if}>{$TITLE}</option>
|
||||||
{/loop}
|
{/loop}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
@@ -59,5 +59,7 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
|
||||||
|
{block name="javascript-init"}{/block}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -0,0 +1,69 @@
|
|||||||
|
{extends file="coupon/type-fragments/base-remove-on-products.html"}
|
||||||
|
|
||||||
|
{block name="discount-field"}
|
||||||
|
<div class="form-group input-free-product-category-id">
|
||||||
|
|
||||||
|
<label for="free-product-category-id">{intl l="Select offrered product category :"}</label>
|
||||||
|
|
||||||
|
<select required class="form-control" id="free-product-category-id" name="{$offered_category_field_name}">
|
||||||
|
<option value="0">{intl l="Please select..."}</option>
|
||||||
|
{loop type="category-tree" category=0 name="list-of-category" backend_context="1"}
|
||||||
|
<option style="padding-left: {$LEVEL * 10}px" value="{$ID}" {if $ID == $offered_category_value}selected="selected"{/if}>{$TITLE}</option>
|
||||||
|
{/loop}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="loading" id="input-free-products-id-loading" style="display: none"></div>
|
||||||
|
|
||||||
|
<div class="form-group" id="input-free-products-id" {if $offered_category_value == 0}style="display: none"{/if}>
|
||||||
|
|
||||||
|
<label for="free-products-id">{intl l="Select offered product :"}</label>
|
||||||
|
|
||||||
|
<select required class="form-control" id="free-products-id" name="{$offered_product_field_name}">
|
||||||
|
{loop type="product" category=$offered_category_value|default:0 name="list-of-products" backend_context="1"}
|
||||||
|
<option value="{$ID}" {if $ID == $offered_product_value}selected="selected"{/if}>{$TITLE}</option>
|
||||||
|
{/loop}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
{/block}
|
||||||
|
|
||||||
|
{block name="javascript-init"}
|
||||||
|
|
||||||
|
// Hide selected products category selection if the
|
||||||
|
// offered product is not yet selected.
|
||||||
|
if ({$offered_category_value|default:0} == 0) {
|
||||||
|
$('.input-coupon-category-id').hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
var $freeCatSelect = $('#free-product-category-id');
|
||||||
|
|
||||||
|
$freeCatSelect.change(function(ev) {
|
||||||
|
|
||||||
|
var $category_id = $(this).val();
|
||||||
|
|
||||||
|
$('.input-coupon-category-id').hide();
|
||||||
|
$('#input-free-products-id').hide();
|
||||||
|
$('#free-products-id').html('');
|
||||||
|
|
||||||
|
if ($category_id != 0) {
|
||||||
|
|
||||||
|
$('#input-free-products-id-loading').show();
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: "{url path='/admin/coupon/type-fragments/ajax-products-list'}",
|
||||||
|
type: 'POST',
|
||||||
|
data: {
|
||||||
|
category_id: $category_id
|
||||||
|
},
|
||||||
|
success: function(options) {
|
||||||
|
$('.input-coupon-category-id').show();
|
||||||
|
$('#free-products-id').html(options);
|
||||||
|
$('#input-free-products-id').show();
|
||||||
|
},
|
||||||
|
complete: function() {
|
||||||
|
$('#input-free-products-id-loading').hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
{/block}
|
||||||
Reference in New Issue
Block a user