diff --git a/templates/backOffice/default/coupon/type-fragments/base-remove-on-attributes.html b/templates/backOffice/default/coupon/type-fragments/base-remove-on-attributes.html index c809002b8..232ab68de 100644 --- a/templates/backOffice/default/coupon/type-fragments/base-remove-on-attributes.html +++ b/templates/backOffice/default/coupon/type-fragments/base-remove-on-attributes.html @@ -19,7 +19,7 @@ @@ -59,5 +59,7 @@ }); } }); - }; + + {block name="javascript-init"}{/block} + } diff --git a/templates/backOffice/default/coupon/type-fragments/base-remove-on-categories.html b/templates/backOffice/default/coupon/type-fragments/base-remove-on-categories.html index 39b81e4c1..1987c6fbf 100644 --- a/templates/backOffice/default/coupon/type-fragments/base-remove-on-categories.html +++ b/templates/backOffice/default/coupon/type-fragments/base-remove-on-categories.html @@ -12,3 +12,9 @@ {intl l='Use Ctrl+click to select (or deselect) more that one category'} + + diff --git a/templates/backOffice/default/coupon/type-fragments/base-remove-on-products.html b/templates/backOffice/default/coupon/type-fragments/base-remove-on-products.html index 3f5cc4a94..db799b5d0 100644 --- a/templates/backOffice/default/coupon/type-fragments/base-remove-on-products.html +++ b/templates/backOffice/default/coupon/type-fragments/base-remove-on-products.html @@ -19,8 +19,8 @@ @@ -59,5 +59,7 @@ }); } }); - }; + + {block name="javascript-init"}{/block} + } diff --git a/templates/backOffice/default/coupon/type-fragments/free-product.html b/templates/backOffice/default/coupon/type-fragments/free-product.html new file mode 100644 index 000000000..05e7bfe14 --- /dev/null +++ b/templates/backOffice/default/coupon/type-fragments/free-product.html @@ -0,0 +1,69 @@ +{extends file="coupon/type-fragments/base-remove-on-products.html"} + +{block name="discount-field"} +
+ + + + +
+ + + +
+ + + + +
+{/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} \ No newline at end of file