Last Updated on Dec 19, 2016 by Jeff Lew
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’ve come up with a simple workaround to get linked products working again with Salemaker. Just follow the simple steps below and you’ll be good to go!
- Open includes/functions_prices.php and find on line 51:
// changed to use master_categories_id // $product_to_categories = $db->Execute("select categories_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$product_id . "'"); // $category = $product_to_categories->fields['categories_id']; $product_to_categories = $db->Execute("select master_categories_id from " . TABLE_PRODUCTS . " where products_id = '" . $product_id . "'"); $category = $product_to_categories->fields['master_categories_id']; $sale = $db->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 <= now() or sale_date_start = '0001-01-01') and (sale_date_end >= now() or sale_date_end = '0001-01-01') and (sale_pricerange_from <= '" . $product_price . "' or sale_pricerange_from = '0') and (sale_pricerange_to >= '" . $product_price . "' or sale_pricerange_to = '0')"); if ($sale->RecordCount() < 1) { return $special_price; }
- Replace with:
// modified by Numinix to support linked products $product_to_categories = $db->Execute("select categories_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$product_id . "'"); $sale_valid = false; while (!$product_to_categories->EOF) { $category = $product_to_categories->fields['categories_id']; $sale = $db->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 <= now() or sale_date_start = '0001-01-01') and (sale_date_end >= now() or sale_date_end = '0001-01-01') and (sale_pricerange_from <= '" . $product_price . "' or sale_pricerange_from = '0') and (sale_pricerange_to >= '" . $product_price . "' or sale_pricerange_to = '0')"); if ($sale->RecordCount() > 0) { $sale_valid = true; break; // break on first matched sale } $product_to_categories->MoveNext(); } if (!$sale_valid) { return $special_price; } // end Numinix modification
And that’s it! Now your products will appear on sale if they are in any sub-category or linked into another category regardless of the master category. Enjoy!