{"id":3091,"date":"2016-12-19T17:47:08","date_gmt":"2016-12-20T00:47:08","guid":{"rendered":"https:\/\/www.numinix.com\/blog\/?p=3091"},"modified":"2016-12-19T17:47:52","modified_gmt":"2016-12-20T00:47:52","slug":"how-to-include-linked-products-in-zen-carts-salemaker-sales","status":"publish","type":"post","link":"https:\/\/www.numinix.com\/blog\/how-to-include-linked-products-in-zen-carts-salemaker-sales\/","title":{"rendered":"How-to Include Linked Products in Zen Cart&#8217;s Salemaker Sales"},"content":{"rendered":"<p>Originally Zen Cart was written to support linked products in Salemaker. However, the original code was buggy and in version 1.3.9h the core Zen Cart developers decided to restrict salemaker to master category IDs. Fortunately, we&#8217;ve come up with a simple workaround to get linked products working again with Salemaker. Just follow the simple steps below and you&#8217;ll be good to go!<\/p>\n<ol>\n<li>Open includes\/functions_prices.php and find on line 51:\n<pre><code>\/\/ changed to use master_categories_id\r\n\/\/\u00a0\u00a0\u00a0\u00a0\u00a0 $product_to_categories = $db-&gt;Execute(\"select categories_id from \" . TABLE_PRODUCTS_TO_CATEGORIES . \" where products_id = '\" . (int)$product_id . \"'\");\r\n\/\/\u00a0\u00a0\u00a0\u00a0\u00a0 $category = $product_to_categories-&gt;fields['categories_id'];\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 $product_to_categories = $db-&gt;Execute(\"select master_categories_id from \" . TABLE_PRODUCTS . \" where products_id = '\" . $product_id . \"'\");\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 $category = $product_to_categories-&gt;fields['master_categories_id'];\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 $sale = $db-&gt;Execute(\"select sale_specials_condition, sale_deduction_value, sale_deduction_type from \" . TABLE_SALEMAKER_SALES . \" where sale_categories_all like '%,\" . $category . \",%' and sale_status = '1' and (sale_date_start &lt;= now() or sale_date_start = '0001-01-01') and (sale_date_end &gt;= now() or sale_date_end = '0001-01-01') and (sale_pricerange_from &lt;= '\" . $product_price . \"' or sale_pricerange_from = '0') and (sale_pricerange_to &gt;= '\" . $product_price . \"' or sale_pricerange_to = '0')\");\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 if ($sale-&gt;RecordCount() &lt; 1) {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 return $special_price;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/code><\/pre>\n<\/li>\n<li>Replace with:\n<pre><code>\/\/ modified by Numinix to support linked products\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 $product_to_categories = $db-&gt;Execute(\"select categories_id from \" . TABLE_PRODUCTS_TO_CATEGORIES . \" where products_id = '\" . (int)$product_id . \"'\");\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 $sale_valid = false;\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 while (!$product_to_categories-&gt;EOF) {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 $category = $product_to_categories-&gt;fields['categories_id'];\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 $sale = $db-&gt;Execute(\"select sale_specials_condition, sale_deduction_value, sale_deduction_type from \" . TABLE_SALEMAKER_SALES . \" where sale_categories_all like '%,\" . $category . \",%' and sale_status = '1' and (sale_date_start &lt;= now() or sale_date_start = '0001-01-01') and (sale_date_end &gt;= now() or sale_date_end = '0001-01-01') and (sale_pricerange_from &lt;= '\" . $product_price . \"' or sale_pricerange_from = '0') and (sale_pricerange_to &gt;= '\" . $product_price . \"' or sale_pricerange_to = '0')\");\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if ($sale-&gt;RecordCount() &gt; 0) {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 $sale_valid = true;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 break; \/\/ break on first matched sale\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 $product_to_categories-&gt;MoveNext();\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 }\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 if (!$sale_valid) {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 return $special_price;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 }\r\n\/\/ end Numinix modification<\/code><\/pre>\n<\/li>\n<\/ol>\n<p>And that&#8217;s it!\u00a0 Now your products will appear on sale if they are in any sub-category or linked into another category regardless of the master category.\u00a0 Enjoy!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Originally Zen Cart was written to support linked products in Salemaker. However, the original code was buggy and in version 1.3.9h the core Zen Cart developers decided to restrict salemaker to master category IDs. Fortunately, we&#8217;ve come up with a simple workaround to get linked products working again with Salemaker. Just follow the simple steps&#8230;<\/p>\n","protected":false},"author":1,"featured_media":3093,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_lmt_disableupdate":"","_lmt_disable":"","_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3],"tags":[686,685,208,8],"class_list":["post-3091","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-zen-cart-optimization","tag-customization","tag-linked-products","tag-salemaker","tag-zen-cart"],"modified_by":"Jeff Lew","jetpack_featured_media_url":"https:\/\/www.numinix.com\/wordpress\/wp-content\/uploads\/2016\/12\/screenshot-www.stringsbymail.com-2016-12-19-16-42-40.png","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.numinix.com\/blog\/wp-json\/wp\/v2\/posts\/3091","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.numinix.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.numinix.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.numinix.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.numinix.com\/blog\/wp-json\/wp\/v2\/comments?post=3091"}],"version-history":[{"count":0,"href":"https:\/\/www.numinix.com\/blog\/wp-json\/wp\/v2\/posts\/3091\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.numinix.com\/blog\/wp-json\/wp\/v2\/media\/3093"}],"wp:attachment":[{"href":"https:\/\/www.numinix.com\/blog\/wp-json\/wp\/v2\/media?parent=3091"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.numinix.com\/blog\/wp-json\/wp\/v2\/categories?post=3091"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.numinix.com\/blog\/wp-json\/wp\/v2\/tags?post=3091"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}