Skip to content

Instantly share code, notes, and snippets.

@genakim
Last active March 16, 2021 13:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save genakim/3a69fe3ec526e976a24b5f744d8796b6 to your computer and use it in GitHub Desktop.
Save genakim/3a69fe3ec526e976a24b5f744d8796b6 to your computer and use it in GitHub Desktop.
1-28382
diff --git a/app/functions/fn.features.php b/app/functions/fn.features.php
index b06227e6b9..31b49f1714 100644
--- a/app/functions/fn.features.php
+++ b/app/functions/fn.features.php
@@ -185,7 +185,19 @@ function fn_update_product_features_value($product_id, $product_features, $add_n
)
) {
$value = empty($value) ? [] : $value;
- $value[] = fn_update_product_feature_variant($feature_id, $feature_type, $add_new_variant[$feature_id], $lang_code);
+ $variant = $add_new_variant[$feature_id]['variant'];
+ if (is_array($variant)) {
+ $variants = $variant;
+ } else {
+ $variants = [$variant];
+ }
+ foreach ($variants as $variant) {
+ $variant_id = fn_update_product_feature_variant($feature_id, $feature_type, ['variant' => $variant], $lang_code);
+ if (!$variant_id) {
+ continue;
+ }
+ $value[] = $variant_id;
+ }
}
if (!empty($value)) {
foreach ($value as $variant_id) {
diff --git a/design/backend/templates/views/product_features/components/variants_picker/picker.tpl b/design/backend/templates/views/product_features/components/variants_picker/picker.tpl
index f64a3bbb88..55f0a3e738 100644
--- a/design/backend/templates/views/product_features/components/variants_picker/picker.tpl
+++ b/design/backend/templates/views/product_features/components/variants_picker/picker.tpl
@@ -84,6 +84,7 @@
data-ca-object-picker-template-result-selector="#product_feature_picker_result_template_{$picker_id}"
data-ca-object-picker-template-selection-selector="#product_feature_picker_selection_template_{$picker_id}"
data-ca-object-picker-template-selection-load-selector="#product_feature_picker_selection_load_template_{$picker_id}"
+ data-ca-object-picker-allow-multiple-created-objects="{$multiple}"
{if $allow_add}
data-ca-object-picker-enable-create-object="true"
data-ca-object-picker-template-result-new-selector="#product_feature_picker_result_new_selector_template_{$picker_id}"
diff --git a/design/backend/templates/views/products/components/product_assign_feature.tpl b/design/backend/templates/views/products/components/product_assign_feature.tpl
index 02b9ac4fd0..011a759cfc 100644
--- a/design/backend/templates/views/products/components/product_assign_feature.tpl
+++ b/design/backend/templates/views/products/components/product_assign_feature.tpl
@@ -60,8 +60,8 @@
value=""
/>
<input type="hidden"
- name="product_data[add_new_variant][{$feature_id}][variant]"
- id="product_feature_{$feature_id}_add_new_variant"
+ name="product_data[add_new_variant][{$feature_id}][variant][]"
+ class="product_feature_{$feature_id}_add_new_variant"
value=""
/>
{include file="views/product_features/components/variants_picker/picker.tpl"
@@ -72,7 +72,7 @@
template_type=$template_type
allow_clear=false
allow_add=$allow_save
- new_value_holder_selector="#product_feature_{$feature_id}_add_new_variant"
+ new_value_holder_selector=".product_feature_{$feature_id}_add_new_variant"
enable_image=$enable_images
}
{elseif $feature.feature_type == "ProductFeatures::SINGLE_CHECKBOX"|enum}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment