Created
July 30, 2019 07:54
-
-
Save incrize/85f742612a3ebda1e36adb57391522b4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/app/addons/master_products/func.php b/app/addons/master_products/func.php | |
index 5b73713530..b5eb5ca118 100644 | |
--- a/app/addons/master_products/func.php | |
+++ b/app/addons/master_products/func.php | |
@@ -935,4 +935,23 @@ function fn_product_variations_master_products_create_vendor_product($master_pro | |
} else { | |
$variation_service->createGroup([$vendor_product_id], null, GroupFeatureCollection::createFromFeatureList($master_product_group['feature_collection'])); | |
} | |
-} | |
\ No newline at end of file | |
+} | |
+ | |
+/** | |
+ * The "check_add_to_cart_post" hook handler. | |
+ * | |
+ * Actions performed: | |
+ * - Prevents the addition of a common product to cart | |
+ * | |
+ * @see fn_check_add_product_to_cart | |
+ */ | |
+function fn_master_products_check_add_to_cart_post($cart, $product, $product_id, &$result) | |
+{ | |
+ if (!$result) { | |
+ return; | |
+ } | |
+ | |
+ $product_company_id = db_get_field('SELECT company_id FROM ?:products WHERE product_id = ?i', $product_id); | |
+ | |
+ $result = !empty($product_company_id); | |
+} | |
diff --git a/app/addons/master_products/init.php b/app/addons/master_products/init.php | |
index 0d260e7487..1602d7f7d7 100644 | |
--- a/app/addons/master_products/init.php | |
+++ b/app/addons/master_products/init.php | |
@@ -51,6 +51,10 @@ fn_register_hooks( | |
'delete_product_post', | |
'tools_change_status', | |
+ // cart | |
+ 'check_add_to_cart_post', | |
+ | |
+ // other | |
'product_type_create_by_product', | |
['get_route', 1950], | |
['url_pre', 1450], | |
diff --git a/design/themes/responsive/templates/addons/master_products/hooks/products/product_data_content.post.tpl b/design/themes/responsive/templates/addons/master_products/hooks/products/product_data_content.post.tpl | |
new file mode 100644 | |
index 0000000000..6c8dbcaed4 | |
--- /dev/null | |
+++ b/design/themes/responsive/templates/addons/master_products/hooks/products/product_data_content.post.tpl | |
@@ -0,0 +1,11 @@ | |
+{if !$product.company_id && $show_view_offers_btn && (!$details_page || $quick_view)} | |
+ {capture name="add_to_cart_`$obj_id`"} | |
+ <div class="cm-reload-{$obj_prefix}{$obj_id} ty-product-offers-btn" id="view_product_offers_btn_{$obj_prefix}{$obj_id}"> | |
+ <a href="{"products.view?product_id=`$product.product_id`"|fn_url}" class="ty-btn__offers ty-btn__primary ty-btn__big ty-btn__add-to-cart ty-btn">{__("master_products.view_product_offers")}</a> | |
+ <!--view_product_offers_btn_{$obj_prefix}{$obj_id}--></div> | |
+ {/capture} | |
+ {if $no_capture} | |
+ {assign var="capture_name" value="add_to_cart_`$obj_id`"} | |
+ {$smarty.capture.$capture_name nofilter} | |
+ {/if} | |
+{/if} | |
\ No newline at end of file | |
diff --git a/design/themes/responsive/templates/addons/master_products/hooks/products/product_data_content.pre.tpl b/design/themes/responsive/templates/addons/master_products/hooks/products/product_data_content.pre.tpl | |
new file mode 100644 | |
index 0000000000..fdf48c796e | |
--- /dev/null | |
+++ b/design/themes/responsive/templates/addons/master_products/hooks/products/product_data_content.pre.tpl | |
@@ -0,0 +1,13 @@ | |
+{if !$product.company_id} | |
+ {if $show_add_to_cart} | |
+ {$show_view_offers_btn=true scope=parent} | |
+ {/if} | |
+ | |
+ {$show_old_price=false scope=parent} | |
+ {$show_list_discount=false scope=parent} | |
+ {$show_product_labels=false scope=parent} | |
+ {$show_discount_label=false scope=parent} | |
+ {$show_shipping_label=false scope=parent} | |
+ {$show_product_amount=false scope=parent} | |
+ {$show_add_to_cart=false scope=parent} | |
+{/if} | |
\ No newline at end of file | |
diff --git a/design/themes/responsive/templates/common/product_data.tpl b/design/themes/responsive/templates/common/product_data.tpl | |
index a5c37b5288..02c74fbb74 100644 | |
--- a/design/themes/responsive/templates/common/product_data.tpl | |
+++ b/design/themes/responsive/templates/common/product_data.tpl | |
@@ -1,3 +1,4 @@ | |
+{hook name="products:product_data_content"} | |
{if $product.tracking == "ProductTracking::TRACK_WITH_OPTIONS"|enum} | |
{assign var="out_of_stock_text" value=__("text_combination_out_of_stock")} | |
{else} | |
@@ -624,5 +625,6 @@ | |
<!--{$object_id}--></div> | |
{/hook} | |
{/foreach} | |
+{/hook} | |
{hook name="products:product_data"}{/hook} | |
diff --git a/design/themes/responsive/templates/views/products/quick_view.tpl b/design/themes/responsive/templates/views/products/quick_view.tpl | |
index 3db76811a7..06a71d5268 100644 | |
--- a/design/themes/responsive/templates/views/products/quick_view.tpl | |
+++ b/design/themes/responsive/templates/views/products/quick_view.tpl | |
@@ -10,6 +10,26 @@ | |
{$obj_prefix=$obj_prefix|default:"ajax"} | |
<div class="ty-product-block" id="product_main_info_{$obj_prefix}"> | |
<div class="ty-product-block__wrapper clearfix"> | |
+ {$show_sku = true} | |
+ {$show_rating = true} | |
+ {$show_old_price = true} | |
+ {$show_price = true} | |
+ {$show_list_discount = true} | |
+ {$show_clean_price = true} | |
+ {$show_product_labels = true} | |
+ {$show_discount_label = true} | |
+ {$show_shipping_label = true} | |
+ {$show_product_amount = true} | |
+ {$show_product_options = true} | |
+ {$min_qty = true} | |
+ {$show_edp = true} | |
+ {$show_add_to_cart = true} | |
+ {$show_list_buttons = true} | |
+ {$block_width = true} | |
+ {$separate_buttons = true} | |
+ {$show_descr = true} | |
+ {$hide_form = $smarty.capture.val_hide_form} | |
+ | |
{hook name="products:view_main_info"} | |
{if $product} | |
@@ -26,29 +46,29 @@ | |
but_role="big" | |
but_text=__("add_to_cart") | |
add_to_cart_meta="cm-form-dialog-closer" | |
- show_sku=true | |
- show_rating=true | |
- show_old_price=true | |
- show_price=true | |
- show_list_discount=true | |
- show_clean_price=true | |
+ show_sku=$show_sku | |
+ show_rating=$show_rating | |
+ show_old_price=$show_old_price | |
+ show_price=$show_price | |
+ show_list_discount=$show_list_discount | |
+ show_clean_price=$show_clean_price | |
details_page=true | |
- show_product_labels=true | |
- show_discount_label=true | |
- show_shipping_label=true | |
- show_product_amount=true | |
- show_product_options=true | |
- hide_form=$smarty.capture.val_hide_form | |
- min_qty=true | |
- show_edp=true | |
- show_add_to_cart=true | |
- show_list_buttons=true | |
+ show_product_labels=$show_product_labels | |
+ show_discount_label=$show_discount_label | |
+ show_shipping_label=$show_shipping_label | |
+ show_product_amount=$show_product_amount | |
+ show_product_options=$show_product_options | |
+ hide_form=$hide_form | |
+ min_qty=$min_qty | |
+ show_edp=$show_edp | |
+ show_add_to_cart=$show_add_to_cart | |
+ show_list_buttons=$show_list_buttons | |
capture_buttons=$smarty.capture.val_capture_buttons | |
capture_options_vs_qty=$smarty.capture.val_capture_options_vs_qty | |
- separate_buttons=true | |
- block_width=true | |
+ separate_buttons=$separate_buttons | |
+ block_width=$block_width | |
no_ajax=$smarty.capture.val_no_ajax | |
- show_descr=true | |
+ show_descr=$show_descr | |
quick_view=true | |
} | |
diff --git a/var/langs/en/addons/master_products.po b/var/langs/en/addons/master_products.po | |
index f40b3d996c..0476b86f6f 100644 | |
--- a/var/langs/en/addons/master_products.po | |
+++ b/var/langs/en/addons/master_products.po | |
@@ -99,3 +99,7 @@ msgstr "Common Products for Vendors: Add-on now works only with global options" | |
msgctxt "Languages::master_products.upgrade_notification.message" | |
msgid "<p>For technical reasons, the <b>[master_product_addon]</b> add-on works only with global options now. If any vendor sells a common product, then we have already converted all options from that product into global options during the upgrade.</p>" | |
msgstr "<p>For technical reasons, the <b>[master_product_addon]</b> add-on works only with global options now. If any vendor sells a common product, then we have already converted all options from that product into global options during the upgrade.</p>" | |
+ | |
+msgctxt "Languages::master_products.view_product_offers" | |
+msgid "See all offers" | |
+msgstr "See all offers" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment