diff --git a/includes/classes/Product.php b/includes/classes/Product.php
new file mode 100644
index 0000000000..2ab60a909a
--- /dev/null
+++ b/includes/classes/Product.php
@@ -0,0 +1,311 @@
+get('property') or ->getData() */
+ public array $fields;
+
+ /** @deprecated use !exists() */
+ public bool $EOF = true;
+
+ public function __construct(protected ?int $product_id = null)
+ {
+ $this->initLanguages();
+
+ if ($this->product_id !== null) {
+ $this->data = $this->loadProductDetails($this->product_id);
+
+ // set some backward compatibility properties
+ $this->fields = $this->data;
+ $this->EOF = empty($this->data);
+ }
+ }
+
+ public function forLanguage(?int $language_id): self
+ {
+ $this->data = $this->getDataForLanguage($language_id);
+ $this->fields = $this->data;
+
+ return $this;
+ }
+
+ public function withDefaultLanguage(): self
+ {
+ $this->data = $this->getDataForLanguage();
+ $this->fields = $this->data;
+
+ return $this;
+ }
+
+ public function getData(): ?array
+ {
+ return $this->data;
+ }
+
+ public function get(string $name)
+ {
+ return $this->data[$name] ?? $this->data['lang'][$this->languages[(int)$_SESSION['languages_id']]] ?? null;
+ }
+
+ /**
+ * Same as getData(), but for specific language only
+ */
+ public function getDataForLanguage(?int $language_id = null): ?array
+ {
+ if (empty($language_id)) {
+ $language_id = (int)$_SESSION['languages_id'];
+ }
+ $data = $this->data;
+
+ // strip all languages except specified one, and merge into parent array instead of sub-array
+ foreach($data['lang'][$this->languages[$language_id]] as $key => $value) {
+ $data[$key] = $value;
+ }
+ unset($data['lang']);
+
+ return $data;
+ }
+
+ public function getId(): ?int
+ {
+ return $this->product_id;
+ }
+
+ public function exists(): bool
+ {
+ return !empty($this->product_id);
+ }
+ public function isValid(): bool
+ {
+ return !empty($this->data);
+ }
+
+ public function isLinked(): bool
+ {
+ return ($this->data['linked_categories_count'] ?? 0) > 0;
+ }
+
+ public function isVirtual(): bool
+ {
+ return ($this->data['products_virtual'] ?? 0) === '1';
+ }
+
+ public function isAlwaysFreeShipping(): bool
+ {
+ return ($this->data['product_is_always_free_shipping'] ?? '') === '1';
+ }
+
+ public function status(): int
+ {
+ return (int)($this->data['products_status'] ?? 0);
+ }
+
+ public function isGiftVoucher(): bool
+ {
+ return str_starts_with($this->data['products_model'] ?? '', 'GIFT');
+ }
+
+ public function allowsAddToCart(): bool
+ {
+ if (empty($this->data)) {
+ return false;
+ }
+
+ $allow_add_to_cart = ($this->data['allow_add_to_cart'] ?? 'N') !== 'N';
+
+ if ($allow_add_to_cart && $this->isGiftVoucher()) {
+ // if GV feature disabled, can't allow GV's to be added to cart
+ if (!defined('MODULE_ORDER_TOTAL_GV_STATUS') || MODULE_ORDER_TOTAL_GV_STATUS !== 'true') {
+ $allow_add_to_cart = false;
+ }
+ }
+
+ $this->notify('NOTIFY_GET_PRODUCT_ALLOW_ADD_TO_CART', $this->product_id, $allow_add_to_cart, $this->data);
+
+ // test for boolean and for 'Y', since observer might try to return 'Y'
+ return in_array($allow_add_to_cart, [true, 'Y'], true);
+ }
+
+ public function getProductQuantity(): int|float
+ {
+ $quantity = $this->data['products_quantity'] ?? '0';
+ $this->notify('NOTIFY_GET_PRODUCT_QUANTITY', $this->product_id, $quantity);
+ return zen_str_to_numeric((string)$quantity);
+ }
+
+ public function getTypeHandler(): string
+ {
+ return ($this->data['type_handler'] ?? 'product');
+ }
+
+ public function getInfoPage(): string
+ {
+ return $this->getTypeHandler() . '_info';
+ }
+
+ public function hasPriceQuantityDiscounts(): bool
+ {
+ if (empty($this->data)) {
+ return false;
+ }
+
+ global $db;
+ $sql = "SELECT products_id FROM " . TABLE_PRODUCTS_DISCOUNT_QUANTITY . " WHERE products_id=" . (int)$this->product_id;
+ $results = $db->Execute($sql, 1);
+ return !$results->EOF;
+ }
+
+ public function hasPriceSpecials()
+ {
+ if (empty($this->data)) {
+ return false;
+ }
+
+ global $db;
+ $sql = "SELECT products_id FROM " . TABLE_SPECIALS . " WHERE products_id=" . (int)$this->product_id;
+ $results = $db->Execute($sql, 1);
+ return !$results->EOF;
+ }
+
+ public function priceIsByAttribute(): bool
+ {
+ return ($this->data['products_priced_by_attribute'] ?? '0') === '1';
+ }
+
+ public function priceIsFree(): bool
+ {
+ return ($this->data['product_is_free'] ?? '0') === '1';
+ }
+
+ public function priceIsCall(): bool
+ {
+ return ($this->data['product_is_call'] ?? '0') === '1';
+ }
+
+ public function __get(string $name)
+ {
+ return $this->get($name);
+ }
+
+ protected function loadProductDetails(int $product_id, ?int $language_id = null): array
+ {
+ global $db;
+
+ $sql = "SELECT p.*, pt.allow_add_to_cart, pt.type_handler, m.manufacturers_name, m.manufacturers_image
+ FROM " . TABLE_PRODUCTS . " p
+ LEFT JOIN " . TABLE_PRODUCT_TYPES . " pt ON (p.products_type = pt.type_id)
+ LEFT JOIN " . TABLE_MANUFACTURERS . " m USING (manufacturers_id)
+ WHERE p.products_id = " . (int)$product_id;
+ $product = $db->Execute($sql, 1, true, 900);
+
+ if ($product->EOF) {
+ return [];
+ }
+
+ $data = $product->fields;
+ $data['id'] = $data['products_id'];
+ $data['product_id'] = $data['products_id'];
+ $data['info_page'] = $data['type_handler'] . '_info';
+ //$data['parent_category_id'] = $data['master_categories_id'];
+
+ /**
+ * Add $data['lang'][code] = [products_name, products_description, etc] for each language
+ */
+ $sql = "SELECT pd.*
+ FROM " . TABLE_PRODUCTS_DESCRIPTION . " pd
+ WHERE pd.products_id = " . (int)$product_id . "
+ ORDER BY language_id";
+ $pd = $db->Execute($sql, null, true, 900);
+ foreach ($pd as $result) {
+ unset($result['products_id']);
+ $data['lang'][$this->languages[$result['language_id']]] = $result;
+ }
+
+ // count linked categories
+ $sql = "SELECT categories_id FROM " . TABLE_PRODUCTS_TO_CATEGORIES . " ptc WHERE products_id=" . (int)$product_id;
+ $results = $db->Execute($sql, null, true, 900);
+ $data['linked_categories_count'] = $results->RecordCount();
+ $data['linked_categories'] = [];
+ foreach($results as $result) {
+ $data['linked_categories'][] = $result['categories_id'];
+ }
+
+ // get cPath
+ $categories = [];
+ zen_get_parent_categories($categories, $data['master_categories_id']);
+ $categories = array_reverse($categories);
+ $categories[] = $data['master_categories_id'];
+ $data['cPath'] = implode('_', $categories);
+
+
+ //Allow an observer to modify details
+ $this->notify('NOTIFY_GET_PRODUCT_OBJECT_DETAILS', $product_id, $data);
+
+ return $data;
+ }
+
+ protected function initLanguages(): void
+ {
+ global $lng;
+
+ if ($lng === null) {
+ $lng = new language();
+ }
+
+ $this->languages = $lng->get_language_list(); // [1 => 'en', 2 => 'fr']
+ }
+}
+
+
+/* This class essentially deprecates the following functions (note Notifier hook differences):
+zen_get_product_details (er, well, it's now a helper to access this class)
+zen_get_products_category_id
+zen_products_id_valid
+zen_get_products_name
+zen_get_products_model
+zen_get_products_status
+zen_get_product_is_linked
+zen_get_products_stock (*)
+zen_get_products_manufacturers_name
+zen_get_products_manufacturers_image
+zen_get_products_manufacturers_id
+zen_get_products_url
+zen_get_products_description
+zen_get_info_page
+zen_get_products_type
+zen_get_products_image (er, well, must call zen_image yourself)
+zen_get_products_virtual
+zen_get_products_allow_add_to_cart
+zen_get_product_is_always_free_shipping
+zen_products_lookup
+zen_get_parent_category_id
+zen_has_product_discounts
+zen_has_product_specials
+zen_get_product_path
+zen_get_products_price_is_free
+zen_get_products_price_is_call
+zen_get_products_price_is_priced_by_attributes
+zen_get_products_quantity_order_min
+zen_get_products_quantity_order_units
+zen_get_products_quantity_order_max
+zen_get_products_qty_box_status
+zen_get_products_quantity_mixed
+
+*/
diff --git a/includes/classes/shopping_cart.php b/includes/classes/shopping_cart.php
index 8a6533d657..50b9eb9d2b 100644
--- a/includes/classes/shopping_cart.php
+++ b/includes/classes/shopping_cart.php
@@ -677,13 +677,12 @@ public function calculate()
$qty = $data['qty'];
$prid = zen_get_prid($uprid);
- $product = zen_get_product_details($prid);
- if ($product->EOF) {
+ $product = (new Product($prid))->withDefaultLanguage()->getData();
+ if (empty($product)) {
$this->removeUprid($uprid);
continue;
}
- $product = $product->fields;
$this->notify('NOTIFY_CART_CALCULATE_PRODUCT_PRICE', $uprid, $product);
$prid = zen_get_prid($product['products_id']);
@@ -1231,15 +1230,13 @@ public function get_products(bool $check_for_valid_cart = false)
$products_array = [];
foreach ($this->contents as $uprid => $data) {
$prid = zen_get_prid($uprid);
- $products = zen_get_product_details($prid);
- if ($products->EOF) {
+ $product = (new Product($prid))->withDefaultLanguage()->getData();
+ if (empty($product)) {
$this->removeUprid($uprid);
continue;
}
- $this->notify('NOTIFY_CART_GET_PRODUCTS_NEXT', $uprid, $products->fields);
-
- $product = $products->fields;
+ $this->notify('NOTIFY_CART_GET_PRODUCTS_NEXT', $uprid, $product);
$products_raw_price = zen_get_retail_or_wholesale_price($product['products_price'], $product['products_price_w']);
$products_price = $products_raw_price;
@@ -1489,8 +1486,7 @@ public function get_content_type($gv_only = false)
} else {
foreach ($this->contents as $uprid => $data) {
$prid = (int)$uprid;
- $free_ship_check = zen_get_product_details($prid);
- $free_ship_check = $free_ship_check->fields;
+ $free_ship_check = (new Product($prid))->withDefaultLanguage()->getData();
if (str_starts_with($free_ship_check['products_model'] ?? '', 'GIFT')) {
// @TODO - fix GIFT price in cart special/attribute
@@ -1584,9 +1580,8 @@ public function get_content_type($gv_only = false)
* Calculate item quantity, bounded by the mixed/min units settings
*
* @param int|string $uprid_to_check product id of item to check
- * @return float
*/
- public function in_cart_mixed($uprid_to_check)
+ public function in_cart_mixed(int|string $uprid_to_check): float|int
{
// if nothing is in cart return 0
if (!is_array($this->contents)) {
@@ -1594,10 +1589,10 @@ public function in_cart_mixed($uprid_to_check)
}
// check if mixed is on
- $product = zen_get_product_details((int)$uprid_to_check);
+ $mixed_status = (new Product((int)$uprid_to_check))->withDefaultLanguage()->get('products_quantity_mixed');
// if mixed attributes is off return qty for current attribute selection
- if ($product->fields['products_quantity_mixed'] === '0') {
+ if ($mixed_status === '0') {
return $this->get_quantity($uprid_to_check);
}
@@ -1630,10 +1625,10 @@ public function in_cart_mixed_discount_quantity($uprid_to_check)
}
// check if mixed is on
- $product = zen_get_product_details((int)$uprid_to_check);
+ $mixed_status = (new Product((int)$uprid_to_check))->withDefaultLanguage()->get('products_mixed_discount_quantity');
// if mixed attributes is off return qty for current attribute selection
- if ($product->fields['products_mixed_discount_quantity'] === '0') {
+ if ($mixed_status === '0') {
return $this->get_quantity($uprid_to_check);
}
@@ -1671,8 +1666,8 @@ public function in_cart_check($check_what, $check_value = '1')
$in_cart_check_qty = 0;
foreach ($this->contents as $uprid => $data) {
// check if field it true
- $product_check = zen_get_product_details(zen_get_prid($uprid));
- if (array_key_exists($check_what, $product_check->fields) && (string)$product_check->fields[$check_what] === (string)$check_value) {
+ $product_check = (new Product(zen_get_prid($uprid)))->withDefaultLanguage()->getData();
+ if (array_key_exists($check_what, $product_check) && (string)$product_check[$check_what] === (string)$check_value) {
$in_cart_check_qty += $data['qty'];
}
}
@@ -2651,10 +2646,10 @@ public function in_cart_product_mixed_changed($product_id, $chk = false)
}
// check if mixed is on
- $product = zen_get_product_details((int)$pr_id);
+ $mixed_status = (new Product((int)$pr_id))->withDefaultLanguage()->get('products_quantity_mixed');
// if mixed attributes is off identify that this product is the last of its kind (which is also the first of its kind).
- if (empty($product->fields['products_quantity_mixed'])) {
+ if (empty($mixed_status)) {
return true;
}
diff --git a/includes/functions/functions_products.php b/includes/functions/functions_products.php
index b274826646..fe965ee1db 100644
--- a/includes/functions/functions_products.php
+++ b/includes/functions/functions_products.php
@@ -13,47 +13,32 @@
*
* @param int $product_id
* @param int $language_id (optional)
- * @return queryFactoryResult
+ * @return Product
*/
-function zen_get_product_details($product_id, $language_id = null)
+function zen_get_product_details($product_id, $language_id = null): Product
{
- global $db, $zco_notifier;
-
- if ($language_id === null) {
- $language_id = $_SESSION['languages_id'] ?? 1;
- }
-
- $sql = "SELECT p.*, pd.*, pt.allow_add_to_cart, pt.type_handler
- FROM " . TABLE_PRODUCTS . " p
- LEFT JOIN " . TABLE_PRODUCT_TYPES . " pt ON (p.products_type = pt.type_id)
- LEFT JOIN " . TABLE_PRODUCTS_DESCRIPTION . " pd ON (p.products_id = pd.products_id AND pd.language_id = " . (int)$language_id . ")
- WHERE p.products_id = " . (int)$product_id;
- $product = $db->Execute($sql, 1, true, 900);
- //Allow an observer to modify details
- $zco_notifier->notify('NOTIFY_GET_PRODUCT_DETAILS', $product_id, $product);
- return $product;
+ return (new Product($product_id))->forLanguage((int)$language_id);
}
-/**
- * @param int $product_id
- * @param null $product_info
- */
-function zen_product_set_header_response($product_id, $product_info = null)
+function zen_product_set_header_response(int|string $product_id, ?Product $product_info = null): void
{
global $zco_notifier, $breadcrumb, $robotsNoIndex;
// make sure we got a dbResponse
if ($product_info === null || !isset($product_info->EOF)) {
- $product_info = zen_get_product_details($product_id);
+ $product_info = new Product($product_id);
}
+
// make sure it's for the current product
if (!isset($product_info->fields['products_id'], $product_info->fields['products_status']) || (int)$product_info->fields['products_id'] !== (int)$product_id) {
- $product_info = zen_get_product_details($product_id);
+ $product_info = new Product($product_id);
}
+ $product = $product_info->getData();
+
$response_code = 200;
- $product_not_found = $product_info->EOF;
+ $product_not_found = empty($product);
$should_throw_404 = $product_not_found;
if ($should_throw_404 === true) {
@@ -62,7 +47,7 @@ function zen_product_set_header_response($product_id, $product_info = null)
global $product_status;
- $product_status = (int)($product_not_found === false && $product_info->fields['products_status'] !== '0') ? $product_info->fields['products_status'] : 0;
+ $product_status = (int)($product_not_found === false && $product['products_status'] !== '0') ? $product['products_status'] : 0;
if ($product_status === 0) {
$response_code = 410;
}
@@ -79,7 +64,7 @@ function zen_product_set_header_response($product_id, $product_info = null)
/**
* optionally update the $product_status, $should_throw_404, $response_code vars via the observer
*/
- $zco_notifier->notify('NOTIFY_PRODUCT_INFO_PRODUCT_STATUS_CHECK', $product_info->fields, $product_status, $should_throw_404, $response_code, $use_custom_response_code);
+ $zco_notifier->notify('NOTIFY_PRODUCT_INFO_PRODUCT_STATUS_CHECK', $product_info, $product_status, $should_throw_404, $response_code, $use_custom_response_code);
if ($use_custom_response_code) {
// skip this function's processing and leave all header handling to the observer.
@@ -107,7 +92,7 @@ function zen_product_set_header_response($product_id, $product_info = null)
* @param int $products_id
* @param int $status
*/
-function zen_set_disabled_upcoming_status($products_id, $status)
+function zen_set_disabled_upcoming_status($products_id, $status): void
{
global $db;
@@ -122,7 +107,7 @@ function zen_set_disabled_upcoming_status($products_id, $status)
* Enable all disabled products whose date_available is prior to the specified date
* @param int $datetime optional timestamp
*/
-function zen_enable_disabled_upcoming($datetime = null)
+function zen_enable_disabled_upcoming($datetime = null): void
{
global $db;
@@ -150,14 +135,14 @@ function zen_enable_disabled_upcoming($datetime = null)
/**
* build date range for "upcoming products" query
*/
-function zen_get_upcoming_date_range()
+function zen_get_upcoming_date_range(): string
{
// 120 days; 24 hours; 60 mins; 60secs
$date_range = time();
$zc_new_date = date('Ymd', $date_range);
// need to check speed on this for larger sites
-// $new_range = ' and date_format(p.products_date_available, \'%Y%m%d\') >' . $zc_new_date;
- $new_range = ' and p.products_date_available >' . $zc_new_date . '235959';
+// $new_range = ' AND date_format(p.products_date_available, \'%Y%m%d\') >' . $zc_new_date;
+ $new_range = ' AND p.products_date_available >' . $zc_new_date . '235959';
return $new_range;
}
@@ -167,7 +152,7 @@ function zen_get_upcoming_date_range()
* @param int $time_limit
* @return string
*/
-function zen_get_new_date_range($time_limit = false)
+function zen_get_new_date_range($time_limit = false): string
{
if ($time_limit == false) {
$time_limit = (int)SHOW_NEW_PRODUCTS_LIMIT;
@@ -203,20 +188,16 @@ function zen_get_new_date_range($time_limit = false)
* @param int $product_id
* @return int|string
*/
-function zen_get_products_category_id($product_id)
+function zen_get_products_category_id($product_id): int|string
{
- $result = zen_get_product_details($product_id);
- if ($result->EOF) {
- return '';
- }
- return $result->fields['master_categories_id'];
+ return (new Product($product_id))->get('master_categories_id') ?? '';
}
/**
* Reset master_categories_id for all products linked to the specified $category_id
* @param int $category_id
*/
-function zen_reset_products_category_as_master($category_id)
+function zen_reset_products_category_as_master($category_id): void
{
global $db;
$sql = "SELECT p.products_id, p.master_categories_id, ptoc.categories_id
@@ -230,7 +211,7 @@ function zen_reset_products_category_as_master($category_id)
}
}
-function zen_reset_all_products_master_categories_id()
+function zen_reset_all_products_master_categories_id(): void
{
global $db;
$sql = "SELECT products_id FROM " . TABLE_PRODUCTS;
@@ -254,7 +235,7 @@ function zen_reset_all_products_master_categories_id()
* @param int $product_id
* @param int $category_id
*/
-function zen_set_product_master_categories_id($product_id, $category_id)
+function zen_set_product_master_categories_id($product_id, $category_id): void
{
global $db;
$sql = "UPDATE " . TABLE_PRODUCTS . "
@@ -271,7 +252,7 @@ function zen_set_product_master_categories_id($product_id, $category_id)
* @param array $exclude
* @return array of categories_id
*/
-function zen_get_linked_categories_for_product($product_id, $exclude = [])
+function zen_get_linked_categories_for_product($product_id, $exclude = []): array
{
global $db;
$exclude = array_filter($exclude, function ($record) {
@@ -296,7 +277,7 @@ function zen_get_linked_categories_for_product($product_id, $exclude = [])
* @param bool $first_only if true, return only the first result (string)
* @return array|integer Array of products_id, or if $first-only true, a single products_id/0 if record not found
*/
-function zen_get_linked_products_for_category($category_id, $first_only = false)
+function zen_get_linked_products_for_category($category_id, bool $first_only = false): int|array
{
global $db;
$sql = "SELECT products_id
@@ -323,7 +304,7 @@ function zen_get_linked_products_for_category($category_id, $first_only = false)
* @param int $product_id
* @param int $category_id
*/
-function zen_link_product_to_category($product_id, $category_id)
+function zen_link_product_to_category($product_id, $category_id): void
{
global $db;
$sql = "INSERT IGNORE INTO " . TABLE_PRODUCTS_TO_CATEGORIES . " (products_id, categories_id)
@@ -335,7 +316,7 @@ function zen_link_product_to_category($product_id, $category_id)
* @param int $product_id
* @param int $category_id
*/
-function zen_unlink_product_from_category($product_id, $category_id)
+function zen_unlink_product_from_category($product_id, $category_id): void
{
global $db;
$sql = "DELETE FROM " . TABLE_PRODUCTS_TO_CATEGORIES . "
@@ -350,7 +331,7 @@ function zen_unlink_product_from_category($product_id, $category_id)
* @param int $product_id
* @param int $master_category_id
*/
-function zen_unlink_product_from_all_linked_categories($product_id, $master_category_id = null)
+function zen_unlink_product_from_all_linked_categories($product_id, $master_category_id = null): void
{
global $db;
if ($master_category_id === null) {
@@ -368,11 +349,12 @@ function zen_unlink_product_from_all_linked_categories($product_id, $master_cate
/**
* Return a product ID with attributes hash
- * @param string|int $prid
+ *
+ * @param int|string $prid
* @param array|string $params
* @return string
*/
-function zen_get_uprid($prid, $params)
+function zen_get_uprid(int|string $prid, array|string $params): string
{
// -----
// The string version of the supplied $prid is returned if:
@@ -424,10 +406,9 @@ function zen_get_prid(string|int $uprid): int
* @param int|string $product_id (while a hashed string is accepted, only the (int) portion is used)
* Check if product_id exists in database
*/
-function zen_products_id_valid($product_id)
+function zen_products_id_valid(int|string $product_id): bool
{
- $product = zen_get_product_details($product_id);
- return !$product->EOF;
+ return (new Product($product_id))->isValid();
}
/**
@@ -436,53 +417,42 @@ function zen_products_id_valid($product_id)
* @param int $product_id The product id of the product who's name we want
* @param int $language_id The language id to use. Defaults to current language
*/
-function zen_get_products_name($product_id, $language_id = null)
+function zen_get_products_name($product_id, $language_id = null): string
{
- $product = zen_get_product_details($product_id, $language_id);
- return ($product->EOF) ? '' : $product->fields['products_name'];
+ $product = (new Product($product_id))->getDataForLanguage($language_id);
+ return $product['products_name'] ?? '';
}
/**
* lookup attributes model
* @param int $product_id
*/
-function zen_get_products_model($product_id)
+function zen_get_products_model($product_id): string
{
- $product = zen_get_product_details($product_id);
- return ($product->EOF) ? '' : $product->fields['products_model'];
+ return (new Product($product_id))->get('products_model') ?? '';
}
/**
* Get the status of a product
* @param int $product_id
*/
-function zen_get_products_status($product_id)
+function zen_get_products_status($product_id): int
{
- $product = zen_get_product_details($product_id);
- return ($product->EOF) ? '' : $product->fields['products_status'];
+ return (new Product($product_id))->status();
}
/**
* check if linked
- * @TODO - check to see whether true/false string responses can be changed to boolean
+ * @TODO - check to see whether 'true'/'false' string responses can be changed to boolean
*
* @param int $product_id
*/
function zen_get_product_is_linked($product_id, $show_count = 'false')
{
- global $db;
-
- $sql = "SELECT * FROM " . TABLE_PRODUCTS_TO_CATEGORIES . (!empty($product_id) ? " where products_id=" . (int)$product_id : "");
- $check_linked = $db->Execute($sql);
- if ($check_linked->RecordCount() > 1) {
- if ($show_count === 'true') {
- return $check_linked->RecordCount();
- } else {
- return 'true';
- }
- } else {
- return 'false';
+ if ($show_count === true || $show_count === 'true') {
+ return (new Product($product_id))->get('linked_categories_count');
}
+ return (new Product($product_id))->isLinked() ? 'true' : 'false';
}
/**
@@ -490,14 +460,14 @@ function zen_get_product_is_linked($product_id, $show_count = 'false')
*
* @param int $products_id The product id of the product whose stock we want
*/
-function zen_get_products_stock($products_id)
+function zen_get_products_stock($products_id): int|float
{
- global $db;
+ global $zco_notifier;
// Give an observer the chance to modify this function's return value.
$products_quantity = 0;
$quantity_handled = false;
- $GLOBALS['zco_notifier']->notify(
+ $zco_notifier->notify(
'ZEN_GET_PRODUCTS_STOCK',
$products_id,
$products_quantity,
@@ -506,9 +476,8 @@ function zen_get_products_stock($products_id)
if ($quantity_handled) {
return $products_quantity;
}
- $products_id = zen_get_prid($products_id);
- $product = zen_get_product_details($products_id);
- return ($product->EOF) ? '0' : $product->fields['products_quantity'];
+
+ return (new Product(zen_get_prid($products_id)))->getProductQuantity();
}
/**
@@ -518,7 +487,7 @@ function zen_get_products_stock($products_id)
* @param int $products_id The product id of the product whose stock is to be checked
* @param int $products_quantity Quantity to compare against
*/
-function zen_check_stock($products_id, $products_quantity)
+function zen_check_stock($products_id, $products_quantity): string
{
global $zco_notifier;
@@ -546,17 +515,9 @@ function zen_check_stock($products_id, $products_quantity)
* @param int $product_id
* @return string
*/
-function zen_get_products_manufacturers_name($product_id)
+function zen_get_products_manufacturers_name($product_id): string
{
- global $db;
-
- $sql = "SELECT m.manufacturers_name
- FROM " . TABLE_PRODUCTS . " p
- LEFT JOIN " . TABLE_MANUFACTURERS . " m USING (manufacturers_id)
- WHERE p.products_id = " . (int)$product_id;
-
- $product = $db->Execute($sql, 1);
- return ($product->EOF) ? '' : $product->fields['manufacturers_name'];
+ return (new Product($product_id))->get('manufacturers_name') ?? '';
}
/**
@@ -564,17 +525,9 @@ function zen_get_products_manufacturers_name($product_id)
* @param int $product_id
* @return string
*/
-function zen_get_products_manufacturers_image($product_id)
+function zen_get_products_manufacturers_image($product_id): string
{
- global $db;
-
- $product_query = "SELECT m.manufacturers_image
- FROM " . TABLE_PRODUCTS . " p
- INNER JOIN " . TABLE_MANUFACTURERS . " m USING (manufacturers_id)
- WHERE p.products_id = " . (int)$product_id;
-
- $product = $db->Execute($product_query, 1);
- return ($product->EOF) ? '' : $product->fields['manufacturers_image'];
+ return (new Product($product_id))->get('manufacturers_image') ?? '';
}
/**
@@ -582,10 +535,9 @@ function zen_get_products_manufacturers_image($product_id)
* @param int $product_id
* @return int
*/
-function zen_get_products_manufacturers_id($product_id)
+function zen_get_products_manufacturers_id($product_id): int
{
- $product = zen_get_product_details($product_id);
- return ($product->EOF) ? 0 : (int)$product->fields['manufacturers_id'];
+ return (new Product($product_id))->get('manufacturers_id') ?? 0;
}
/**
@@ -593,10 +545,10 @@ function zen_get_products_manufacturers_id($product_id)
* @param int $language_id
* @return string
*/
-function zen_get_products_url($product_id, $language_id)
+function zen_get_products_url($product_id, $language_id): string
{
- $product = zen_get_product_details($product_id, $language_id);
- return ($product->EOF) ? '' : (string)$product->fields['products_url'];
+ $product = (new Product($product_id))->getDataForLanguage($language_id);
+ return $product['products_url'] ?? '';
}
/**
@@ -605,15 +557,16 @@ function zen_get_products_url($product_id, $language_id)
* @param int $language_id
* @return string
*/
-function zen_get_products_description($product_id, $language_id = null)
+function zen_get_products_description($product_id, $language_id = null): string
{
global $zco_notifier;
- $product = zen_get_product_details($product_id, $language_id);
+ $product = new Product($product_id);
+ $data = $product->getDataForLanguage($language_id);
//Allow an observer to modify the description
- $zco_notifier->notify('NOTIFY_GET_PRODUCTS_DESCRIPTION', $product_id, $product);
- return ($product->EOF) ? '' : $product->fields['products_description'];
+ $zco_notifier->notify('NOTIFY_GET_PRODUCTS_DESCRIPTION', $product_id, $data);
+ return $data['products_description'] ?? '';
}
/**
@@ -621,10 +574,9 @@ function zen_get_products_description($product_id, $language_id = null)
* @param int $product_id
* @return string
*/
-function zen_get_info_page($product_id)
+function zen_get_info_page($product_id): string
{
- $result = zen_get_product_details($product_id);
- return ($result->EOF) ? 'product_info' : ($result->fields['type_handler'] . '_info');
+ return (new Product($product_id))->getInfoPage();
}
/**
@@ -632,15 +584,10 @@ function zen_get_info_page($product_id)
* @param int $product_id
* @return int|string
*/
-function zen_get_products_type($product_id)
+function zen_get_products_type($product_id): int|string
{
- $result = zen_get_product_details($product_id);
-
- // -----
- // NOTE: Empty string return is used by the admin/product.php to identify a product
- // that doesn't exist in the database!
- //
- return ($result->EOF) ? '' : (int)$result->fields['products_type'];
+ // NOTE: Empty string return is used by the admin/product.php to identify a product that doesn't exist in the database!
+ return (new Product($product_id))->get('products_type') ?? '';
}
/**
@@ -650,17 +597,17 @@ function zen_get_products_type($product_id)
* @param int $height
* @return string
*/
-function zen_get_products_image($product_id, $width = SMALL_IMAGE_WIDTH, $height = SMALL_IMAGE_HEIGHT)
+function zen_get_products_image($product_id, $width = SMALL_IMAGE_WIDTH, $height = SMALL_IMAGE_HEIGHT): string
{
- $result = zen_get_product_details($product_id);
- if ($result->EOF) {
+ $image = (new Product($product_id))->get('products_image') ?? '';
+ if (empty($image)) {
return '';
}
if (IS_ADMIN_FLAG === true) {
- return $result->fields['products_image'];
+ return $image;
}
- return zen_image(DIR_WS_IMAGES . $result->fields['products_image'], zen_get_products_name($product_id), $width, $height);
+ return zen_image(DIR_WS_IMAGES . $image, zen_get_products_name($product_id), $width, $height);
}
/**
@@ -668,10 +615,9 @@ function zen_get_products_image($product_id, $width = SMALL_IMAGE_WIDTH, $height
* @param int $product_id
* @return bool
*/
-function zen_get_products_virtual($product_id)
+function zen_get_products_virtual($product_id): bool
{
- $result = zen_get_product_details($product_id);
- return (!$result->EOF && $result->fields['products_virtual'] === '1');
+ return (new Product($product_id))->isVirtual();
}
/**
@@ -679,26 +625,9 @@ function zen_get_products_virtual($product_id)
* @param int|string $product_id (while a hashed string is accepted, only the (int) portion is used)
* @return string Y|N
*/
-function zen_get_products_allow_add_to_cart($product_id)
+function zen_get_products_allow_add_to_cart($product_id): string
{
- global $zco_notifier;
-
- $product_query_results = zen_get_product_details($product_id);
-
- // If product found, and product_type's allow_add_to_cart is not 'N', allow
- $allow_add_to_cart = !$product_query_results->EOF && $product_query_results->fields['allow_add_to_cart'] !== 'N';
-
- // If product is encoded as GV but GV feature is turned off, disallow add-to-cart
- if ($allow_add_to_cart === true && strpos(($product_query_results->fields['products_model'] ?? ''), 'GIFT') === 0) {
- if (!defined('MODULE_ORDER_TOTAL_GV_STATUS') || MODULE_ORDER_TOTAL_GV_STATUS !== 'true') {
- $allow_add_to_cart = false;
- }
- }
-
- $zco_notifier->notify('NOTIFY_GET_PRODUCT_ALLOW_ADD_TO_CART', $product_id, $allow_add_to_cart, $product_query_results);
-
- // test for boolean and for 'Y', since observer might try to return 'Y'
- return in_array($allow_add_to_cart, [true, 'Y'], true) ? 'Y' : 'N';
+ return (new Product($product_id))->allowsAddToCart() ? 'Y' : 'N';
}
/**
@@ -710,7 +639,7 @@ function zen_get_products_allow_add_to_cart($product_id)
* the value of the configuration_key is then returned
* NOTE: keys are looked up first in the product_type_layout table and if not found looked up in the configuration table.
*/
-function zen_get_show_product_switch($lookup, $field, $prefix = 'SHOW_', $suffix = '_INFO', $field_prefix = '_', $field_suffix = '')
+function zen_get_show_product_switch($lookup, $field, $prefix = 'SHOW_', $suffix = '_INFO', $field_prefix = '_', $field_suffix = ''): string
{
global $db;
$keyName = zen_get_show_product_switch_name($lookup, $field, $prefix, $suffix, $field_prefix, $field_suffix);
@@ -732,10 +661,9 @@ function zen_get_show_product_switch($lookup, $field, $prefix = 'SHOW_', $suffix
/**
* return switch name
*/
-function zen_get_show_product_switch_name($lookup, $field, $prefix = 'SHOW_', $suffix = '_INFO', $field_prefix = '_', $field_suffix = '')
+function zen_get_show_product_switch_name($lookup, $field, $prefix = 'SHOW_', $suffix = '_INFO', $field_prefix = '_', $field_suffix = ''): string
{
- $product = zen_get_product_details((int)$lookup);
- $type_handler = ($product->EOF) ? 'product' : $product->fields['type_handler'];
+ $type_handler = (new Product((int)$lookup))->getTypeHandler();
return strtoupper($prefix . $type_handler . $suffix . $field_prefix . $field . $field_suffix);
}
@@ -746,8 +674,7 @@ function zen_get_show_product_switch_name($lookup, $field, $prefix = 'SHOW_', $s
*/
function zen_get_product_is_always_free_shipping($product_id): bool
{
- $look_up = zen_get_product_details($product_id);
- return (!$look_up->EOF && $look_up->fields['product_is_always_free_shipping'] === '1');
+ return (new Product($product_id))->isAlwaysFreeShipping();
}
/**
@@ -756,14 +683,17 @@ function zen_get_product_is_always_free_shipping($product_id): bool
* @param int $product_id
* @param string $what_field
* @param int $language ID
+ *
+ * @deprecated use Product class ->get($what_field) instead
*/
-function zen_products_lookup($product_id, $what_field = 'products_name', $language = null)
+function zen_products_lookup($product_id, $what_field = 'products_name', $language = null): mixed
{
- $product_lookup = zen_get_product_details($product_id, $language);
- if ($product_lookup->EOF || !array_key_exists($what_field, $product_lookup->fields)) {
+ $product = new Product($product_id);
+ $data = $product->getDataForLanguage($language);
+ if (empty($data) || !array_key_exists($what_field, $data)) {
return '';
}
- return $product_lookup->fields[$what_field];
+ return $data[$what_field];
}
/**
@@ -771,10 +701,9 @@ function zen_products_lookup($product_id, $what_field = 'products_name', $langua
* @param int $product_id
* @return mixed|int
*/
-function zen_get_parent_category_id($product_id)
+function zen_get_parent_category_id($product_id): int|string
{
- $result = zen_get_product_details($product_id);
- return ($result->EOF) ? '' : $result->fields['master_categories_id'];
+ return (new Product($product_id))->get('master_categories_id') ?? '';
}
/**
@@ -814,7 +743,7 @@ function zen_has_product_specials(int $product_id): bool
* @param int $product_id
* @param int $status
*/
-function zen_set_product_status($product_id, $status)
+function zen_set_product_status($product_id, $status): void
{
global $db;
$db->Execute(
@@ -831,7 +760,7 @@ function zen_set_product_status($product_id, $status)
* @param int $product_id
* @param string $ptc
*/
-function zen_remove_product($product_id, $ptc = 'true')
+function zen_remove_product($product_id, $ptc = 'true'): void
{
global $db, $zco_notifier;
$zco_notifier->notify('NOTIFIER_ADMIN_ZEN_REMOVE_PRODUCT', [], $product_id, $ptc);
@@ -924,7 +853,7 @@ function zen_remove_product($product_id, $ptc = 'true')
*
* @param int $product_id
*/
-function zen_products_attributes_download_delete($product_id)
+function zen_products_attributes_download_delete($product_id): void
{
global $db, $zco_notifier;
$zco_notifier->notify('NOTIFIER_ADMIN_ZEN_PRODUCTS_ATTRIBUTES_DOWNLOAD_DELETE', [], $product_id);
@@ -942,7 +871,8 @@ function zen_products_attributes_download_delete($product_id)
* @param int $copy_to Target products_id
* @return bool Indicates whether there was a special on $copy_from or not.
*/
-function zen_copy_specials_to_product(int $copy_from, int $copy_to): bool {
+function zen_copy_specials_to_product(int $copy_from, int $copy_to): bool
+{
global $db;
// Fetch existing special for $copy_from, if any.
@@ -975,7 +905,7 @@ function zen_copy_specials_to_product(int $copy_from, int $copy_to): bool {
* @param int $copy_to
* @return false on failure
*/
-function zen_copy_discounts_to_product($copy_from, $copy_to)
+function zen_copy_discounts_to_product($copy_from, $copy_to): bool
{
global $db;
diff --git a/includes/modules/also_purchased_products.php b/includes/modules/also_purchased_products.php
index 77bbeeb2a0..101c0e3022 100644
--- a/includes/modules/also_purchased_products.php
+++ b/includes/modules/also_purchased_products.php
@@ -1,4 +1,5 @@
0 && MIN_DISPLAY_ALSO_PURCHASED > 0) {
+ $also_purchased_products = $db->ExecuteRandomMulti(sprintf(SQL_ALSO_PURCHASED, (int)$_GET['products_id'], (int)$_GET['products_id']), (int)MAX_DISPLAY_ALSO_PURCHASED);
- $also_purchased_products = $db->ExecuteRandomMulti(sprintf(SQL_ALSO_PURCHASED, (int)$_GET['products_id'], (int)$_GET['products_id']), (int)MAX_DISPLAY_ALSO_PURCHASED);
+ $num_products_ordered = $also_purchased_products->RecordCount();
- $num_products_ordered = $also_purchased_products->RecordCount();
+ $row = 0;
+ $col = 0;
+ $list_box_contents = [];
+ $title = '';
- $row = 0;
- $col = 0;
- $list_box_contents = [];
- $title = '';
+ // show only when 1 or more and equal to or greater than minimum set in admin
+ if ($num_products_ordered >= MIN_DISPLAY_ALSO_PURCHASED && $num_products_ordered > 0) {
+ if ($num_products_ordered < SHOW_PRODUCT_INFO_COLUMNS_ALSO_PURCHASED_PRODUCTS) {
+ $col_width = floor(100 / $num_products_ordered);
+ } else {
+ $col_width = floor(100 / SHOW_PRODUCT_INFO_COLUMNS_ALSO_PURCHASED_PRODUCTS);
+ }
- // show only when 1 or more and equal to or greater than minimum set in admin
- if ($num_products_ordered >= MIN_DISPLAY_ALSO_PURCHASED && $num_products_ordered > 0) {
- if ($num_products_ordered < SHOW_PRODUCT_INFO_COLUMNS_ALSO_PURCHASED_PRODUCTS) {
- $col_width = floor(100/$num_products_ordered);
- } else {
- $col_width = floor(100/SHOW_PRODUCT_INFO_COLUMNS_ALSO_PURCHASED_PRODUCTS);
- }
+ while (!$also_purchased_products->EOF) {
+ $product_info = new Product($also_purchased_products->fields['products_id']);
+ $data = array_merge($also_purchased_products->fields, $product_info->getDataForLanguage());
- while (!$also_purchased_products->EOF) {
- $also_purchased_products->fields['products_name'] = zen_get_products_name($also_purchased_products->fields['products_id']);
- $list_box_contents[$row][$col] = [
- 'params' => 'class="centerBoxContentsAlsoPurch"' . ' ' . 'style="width:' . $col_width . '%;"',
- 'text' => ((empty($also_purchased_products->fields['products_image']) && (int)PRODUCTS_IMAGE_NO_IMAGE_STATUS === 0) ? '' : '' . zen_image(DIR_WS_IMAGES . $also_purchased_products->fields['products_image'], $also_purchased_products->fields['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '
') . '' . $also_purchased_products->fields['products_name'] . ''
- ];
+ $list_box_contents[$row][$col] = [
+ 'params' => 'class="centerBoxContentsAlsoPurch"' . ' ' . 'style="width:' . $col_width . '%;"',
+ 'text' => ((empty($data['products_image']) && (int)PRODUCTS_IMAGE_NO_IMAGE_STATUS === 0) ? ''
+ : ''
+ . zen_image(DIR_WS_IMAGES . $data['products_image'], $data['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT)
+ . '
')
+ . '' . $data['products_name'] . '',
+ ];
- $col ++;
- if ($col > (SHOW_PRODUCT_INFO_COLUMNS_ALSO_PURCHASED_PRODUCTS - 1)) {
- $col = 0;
- $row ++;
- }
- $also_purchased_products->MoveNextRandom();
+ $col++;
+ if ($col > (SHOW_PRODUCT_INFO_COLUMNS_ALSO_PURCHASED_PRODUCTS - 1)) {
+ $col = 0;
+ $row++;
+ }
+ $also_purchased_products->MoveNextRandom();
+ }
+ }
+ if ($also_purchased_products->RecordCount() > 0 && $also_purchased_products->RecordCount() >= MIN_DISPLAY_ALSO_PURCHASED) {
+ $title = '
' . TEXT_ALSO_PURCHASED_PRODUCTS . '
';
+ $zc_show_also_purchased = true;
}
- }
- if ($also_purchased_products->RecordCount() > 0 && $also_purchased_products->RecordCount() >= MIN_DISPLAY_ALSO_PURCHASED) {
- $title = '' . TEXT_ALSO_PURCHASED_PRODUCTS . '
';
- $zc_show_also_purchased = true;
- }
}
diff --git a/includes/modules/featured_products.php b/includes/modules/featured_products.php
index 68205b35b6..d24f44a518 100644
--- a/includes/modules/featured_products.php
+++ b/includes/modules/featured_products.php
@@ -1,4 +1,5 @@
0 && empty($_GET['filter_id'])) || !empty($_GET['music_genre_id']) || !empty($_GET['record_company_id'])) || empty($new_products_category_id) ) {
- $featured_products_query = "SELECT p.products_id, p.products_image, pd.products_name, p.master_categories_id
- FROM " . TABLE_PRODUCTS . " p
- LEFT JOIN " . TABLE_FEATURED . " f ON p.products_id = f.products_id
- LEFT JOIN " . TABLE_PRODUCTS_DESCRIPTION . " pd ON p.products_id = pd.products_id
- AND pd.language_id = " . (int)$_SESSION['languages_id'] . "
- WHERE p.products_status = 1
- AND f.status = 1";
+if ((($manufacturers_id > 0 && empty($_GET['filter_id'])) || !empty($_GET['music_genre_id']) || !empty($_GET['record_company_id'])) || empty($new_products_category_id)) {
+ $sql = "SELECT p.products_id, p.products_image, pd.products_name, p.master_categories_id
+ FROM " . TABLE_PRODUCTS . " p
+ LEFT JOIN " . TABLE_FEATURED . " f ON p.products_id = f.products_id
+ LEFT JOIN " . TABLE_PRODUCTS_DESCRIPTION . " pd ON p.products_id = pd.products_id
+ AND pd.language_id = " . (int)$_SESSION['languages_id'] . "
+ WHERE p.products_status = 1
+ AND f.status = 1";
} else {
- // get all products and cPaths in this subcat tree
- $productsInCategory = zen_get_categories_products_list( (($manufacturers_id > 0 && !empty($_GET['filter_id'])) ? zen_get_generated_category_path_rev($_GET['filter_id']) : $cPath), false, true, 0, $display_limit);
+ // get all products and cPaths in this subcat tree
+ $productsInCategory = zen_get_categories_products_list((($manufacturers_id > 0 && !empty($_GET['filter_id'])) ? zen_get_generated_category_path_rev($_GET['filter_id']) : $cPath), false, true, 0, $display_limit);
- if (is_array($productsInCategory) && sizeof($productsInCategory) > 0) {
- // build products-list string to insert into SQL query
- foreach($productsInCategory as $key => $value) {
- $list_of_products .= $key . ', ';
+ if (is_array($productsInCategory) && count($productsInCategory) > 0) {
+ // build products-list string to insert into SQL query
+ foreach ($productsInCategory as $key => $value) {
+ $list_of_products .= $key . ', ';
+ }
+ $list_of_products = substr($list_of_products, 0, -2); // remove trailing comma
+ $sql = "SELECT p.products_id, p.products_image, pd.products_name, p.master_categories_id
+ FROM " . TABLE_PRODUCTS . " p
+ LEFT JOIN " . TABLE_FEATURED . " f ON p.products_id = f.products_id
+ LEFT JOIN " . TABLE_PRODUCTS_DESCRIPTION . " pd ON p.products_id = pd.products_id
+ AND pd.language_id = " . (int)$_SESSION['languages_id'] . "
+ WHERE p.products_status = 1
+ AND f.status = 1
+ AND p.products_id IN (" . $list_of_products . ")";
}
- $list_of_products = substr($list_of_products, 0, -2); // remove trailing comma
- $featured_products_query = "SELECT p.products_id, p.products_image, pd.products_name, p.master_categories_id
- FROM " . TABLE_PRODUCTS . " p
- LEFT JOIN " . TABLE_FEATURED . " f ON p.products_id = f.products_id
- LEFT JOIN " . TABLE_PRODUCTS_DESCRIPTION . " pd ON p.products_id = pd.products_id
- AND pd.language_id = " . (int)$_SESSION['languages_id'] . "
- WHERE p.products_status = 1
- AND f.status = 1
- AND p.products_id IN (" . $list_of_products . ")";
- }
}
-if ($featured_products_query != '') $featured_products = $db->ExecuteRandomMulti($featured_products_query, MAX_DISPLAY_SEARCH_RESULTS_FEATURED);
+if ($sql !== '') {
+ $featured_products = $db->ExecuteRandomMulti($sql, MAX_DISPLAY_SEARCH_RESULTS_FEATURED);
+}
$row = 0;
$col = 0;
-$list_box_contents = array();
+$list_box_contents = [];
$title = '';
-$num_products_count = ($featured_products_query == '') ? 0 : $featured_products->RecordCount();
+$num_products_count = ($sql === '') ? 0 : $featured_products->RecordCount();
// show only when 1 or more
if ($num_products_count > 0) {
- if ($num_products_count < SHOW_PRODUCT_INFO_COLUMNS_FEATURED_PRODUCTS || SHOW_PRODUCT_INFO_COLUMNS_FEATURED_PRODUCTS == 0) {
- $col_width = floor(100/$num_products_count);
- } else {
- $col_width = floor(100/SHOW_PRODUCT_INFO_COLUMNS_FEATURED_PRODUCTS);
- }
- while (!$featured_products->EOF) {
- $products_price = zen_get_products_display_price($featured_products->fields['products_id']);
- if (!isset($productsInCategory[$featured_products->fields['products_id']])) $productsInCategory[$featured_products->fields['products_id']] = zen_get_generated_category_path_rev($featured_products->fields['master_categories_id']);
+ if ($num_products_count < SHOW_PRODUCT_INFO_COLUMNS_FEATURED_PRODUCTS || SHOW_PRODUCT_INFO_COLUMNS_FEATURED_PRODUCTS == 0) {
+ $col_width = floor(100 / $num_products_count);
+ } else {
+ $col_width = floor(100 / SHOW_PRODUCT_INFO_COLUMNS_FEATURED_PRODUCTS);
+ }
+ while (!$featured_products->EOF) {
+ $product_info = new Product($featured_products->fields['products_id']);
+ $data = $product_info->getDataForLanguage();
+
+ $products_price = zen_get_products_display_price($data['products_id']);
+ if (!isset($productsInCategory[$data['products_id']])) {
+ $productsInCategory[$data['products_id']] = zen_get_generated_category_path_rev($data['master_categories_id']);
+ }
- $zco_notifier->notify('NOTIFY_MODULES_FEATURED_PRODUCTS_B4_LIST_BOX', array(), $featured_products->fields, $products_price);
+ $zco_notifier->notify('NOTIFY_MODULES_FEATURED_PRODUCTS_B4_LIST_BOX', [], $data, $products_price);
- $list_box_contents[$row][$col] = array('params' =>'class="centerBoxContentsFeatured centeredContent back"' . ' ' . 'style="width:' . $col_width . '%;"',
- 'text' => (($featured_products->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) ? '' : '' . zen_image(DIR_WS_IMAGES . $featured_products->fields['products_image'], $featured_products->fields['products_name'], IMAGE_FEATURED_PRODUCTS_LISTING_WIDTH, IMAGE_FEATURED_PRODUCTS_LISTING_HEIGHT) . '
') . '' . $featured_products->fields['products_name'] . '
' . $products_price);
+ $list_box_contents[$row][$col] = [
+ 'params' => 'class="centerBoxContentsFeatured centeredContent back"' . ' ' . 'style="width:' . $col_width . '%;"',
+ 'text' => (($data['products_image'] === '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) ? ''
+ : ''
+ . zen_image(DIR_WS_IMAGES . $data['products_image'], $data['products_name'], IMAGE_FEATURED_PRODUCTS_LISTING_WIDTH, IMAGE_FEATURED_PRODUCTS_LISTING_HEIGHT)
+ . '
')
+ . '' . $data['products_name']
+ . '
' . $products_price,
+ ];
- $col ++;
- if ($col > (SHOW_PRODUCT_INFO_COLUMNS_FEATURED_PRODUCTS - 1)) {
- $col = 0;
- $row ++;
+ $col++;
+ if ($col > (SHOW_PRODUCT_INFO_COLUMNS_FEATURED_PRODUCTS - 1)) {
+ $col = 0;
+ $row++;
+ }
+ $featured_products->MoveNextRandom();
}
- $featured_products->MoveNextRandom();
- }
- if ($featured_products->RecordCount() > 0) {
- if (!empty($current_category_id)) {
- $category_title = zen_get_category_name((int)$current_category_id);
- $title = '' . TABLE_HEADING_FEATURED_PRODUCTS . ($category_title != '' ? ' - ' . $category_title : '') . '
';
- } else {
- $title = '' . TABLE_HEADING_FEATURED_PRODUCTS . '
';
+ if ($featured_products->RecordCount() > 0) {
+ if (!empty($current_category_id)) {
+ $category_title = zen_get_category_name((int)$current_category_id);
+ $title = '' . TABLE_HEADING_FEATURED_PRODUCTS . ($category_title !== '' ? ' - ' . $category_title : '') . '
';
+ } else {
+ $title = '' . TABLE_HEADING_FEATURED_PRODUCTS . '
';
+ }
+ $zc_show_featured = true;
}
- $zc_show_featured = true;
- }
}
diff --git a/includes/modules/new_products.php b/includes/modules/new_products.php
index 3f8185d6d7..fe0fdf1a96 100644
--- a/includes/modules/new_products.php
+++ b/includes/modules/new_products.php
@@ -70,7 +70,7 @@
$products_price = zen_get_products_display_price($new_products_id);
$new_products_link = zen_href_link(zen_get_info_page($new_products_id), 'cPath=' . $productsInCategory[$new_products_id] . '&products_id=' . $new_products_id);
- $new_products_name = $new_products->fields['products_name'];
+ $new_products_name = zen_get_products_name($new_products->fields['products_id']);
if ($new_products->fields['products_image'] === '' && PRODUCTS_IMAGE_NO_IMAGE_STATUS === '0') {
$new_products_image = '';
@@ -98,7 +98,7 @@
if (!empty($current_category_id)) {
$category_title = zen_get_category_name((int)$current_category_id);
- $title = '' . sprintf(TABLE_HEADING_NEW_PRODUCTS, $zcDate->output('%B')) . ($category_title != '' ? ' - ' . $category_title : '' ) . '
';
+ $title = '' . sprintf(TABLE_HEADING_NEW_PRODUCTS, $zcDate->output('%B')) . ($category_title !== '' ? ' - ' . $category_title : '' ) . '
';
} else {
$title = '' . sprintf(TABLE_HEADING_NEW_PRODUCTS, $zcDate->output('%B')) . '
';
}
diff --git a/includes/modules/pages/document_general_info/header_php.php b/includes/modules/pages/document_general_info/header_php.php
index c44c674db9..b934912416 100644
--- a/includes/modules/pages/document_general_info/header_php.php
+++ b/includes/modules/pages/document_general_info/header_php.php
@@ -13,9 +13,9 @@
require(DIR_WS_MODULES . zen_get_module_directory('require_languages.php'));
-$product_info = zen_get_product_details($products_id_current = (!empty($_GET['products_id']) ? (int)$_GET['products_id'] : 0));
-if (!empty($product_info->fields['type_handler']) && $current_page !== $product_info->fields['type_handler'] . '_info') {
- zen_redirect(zen_href_link($product_info->fields['type_handler'] . '_info', zen_get_all_get_params()));
+$product_info = new Product($products_id_current = (!empty($_GET['products_id']) ? (int)$_GET['products_id'] : 0));
+if ($current_page !== $product_info->get('info_page')) {
+ zen_redirect(zen_href_link($product_info->get('info_page'), zen_get_all_get_params()));
}
zen_product_set_header_response($products_id_current, $product_info);
diff --git a/includes/modules/pages/document_general_info/main_template_vars.php b/includes/modules/pages/document_general_info/main_template_vars.php
index 140096054b..7a8d0b58c3 100644
--- a/includes/modules/pages/document_general_info/main_template_vars.php
+++ b/includes/modules/pages/document_general_info/main_template_vars.php
@@ -14,11 +14,13 @@
// This should be first line of the script:
$zco_notifier->notify('NOTIFY_MAIN_TEMPLATE_VARS_START_DOCUMENT_GENERAL_INFO');
- if (!isset($product_info->EOF, $product_info->fields['products_id'], $product_info->fields['products_status']) || (int)$product_info->fields['products_id'] !== (int)$_GET['products_id']) {
- $product_info = zen_get_product_details($_GET['products_id']);
+ $product_info = $product_info ?? new Product($_GET['products_id']);
+
+ if (!isset($product_info->fields['products_id'], $product_info->fields['products_status']) || (int)$product_info->fields['products_id'] !== (int)$_GET['products_id']) {
+ $product_info = new Product($_GET['products_id']);
}
- $product_not_found = $product_info->EOF;
+ $product_not_found = !$product_info->exists();
if (!defined('DISABLED_PRODUCTS_TRIGGER_HTTP200') || DISABLED_PRODUCTS_TRIGGER_HTTP200 !== 'true') {
if (!$product_not_found && $product_info->fields['products_status'] != 1) {
@@ -38,7 +40,7 @@
$products_price = $currencies->display_price($product_info->fields['products_price'], zen_get_tax_rate($product_info->fields['products_tax_class_id']));
- $manufacturers_name= zen_get_products_manufacturers_name((int)$_GET['products_id']);
+ $manufacturers_name = $product_info->fields['manufacturers_name'];
if ($new_price = zen_get_products_special_price($product_info->fields['products_id'])) {
$specials_price = $currencies->display_price($new_price, zen_get_tax_rate($product_info->fields['products_tax_class_id']));
@@ -61,17 +63,17 @@
$reviews = $db->Execute($reviews_query);
- $products_name = $product_info->fields['products_name'];
+ $products_name = $product_info->fields['lang'][$_SESSION['languages_code']]['products_name'];
$products_model = $product_info->fields['products_model'];
// if no common markup tags in description, add line breaks for readability:
- $products_description = (!preg_match('/(
fields['products_description']) ? nl2br($product_info->fields['products_description']) : $product_info->fields['products_description']);
+ $products_description = (!preg_match('/(
fields['lang'][$_SESSION['languages_code']]['products_description']) ? nl2br($product_info->fields['lang'][$_SESSION['languages_code']]['products_description']) : $product_info->fields['lang'][$_SESSION['languages_code']]['products_description']);
$products_image = (($product_not_found || $product_info->fields['products_image'] == '') && PRODUCTS_IMAGE_NO_IMAGE_STATUS == '1') ? PRODUCTS_IMAGE_NO_IMAGE : '';
if ($product_info->fields['products_image'] != '' || PRODUCTS_IMAGE_NO_IMAGE_STATUS != '1') {
$products_image = $product_info->fields['products_image'];
}
- $products_url = $product_info->fields['products_url'];
+ $products_url = $product_info->fields['lang'][$_SESSION['languages_code']]['products_url'];
$products_date_available = $product_info->fields['products_date_available'];
$products_date_added = $product_info->fields['products_date_added'];
$products_manufacturer = $manufacturers_name;
diff --git a/includes/modules/pages/document_product_info/header_php.php b/includes/modules/pages/document_product_info/header_php.php
index 046b4809af..b96f76d1fe 100644
--- a/includes/modules/pages/document_product_info/header_php.php
+++ b/includes/modules/pages/document_product_info/header_php.php
@@ -13,9 +13,9 @@
require(DIR_WS_MODULES . zen_get_module_directory('require_languages.php'));
-$product_info = zen_get_product_details($products_id_current = (!empty($_GET['products_id']) ? (int)$_GET['products_id'] : 0));
-if (!empty($product_info->fields['type_handler']) && $current_page !== $product_info->fields['type_handler'] . '_info') {
- zen_redirect(zen_href_link($product_info->fields['type_handler'] . '_info', zen_get_all_get_params()));
+$product_info = new Product($products_id_current = (!empty($_GET['products_id']) ? (int)$_GET['products_id'] : 0));
+if ($current_page !== $product_info->get('info_page')) {
+ zen_redirect(zen_href_link($product_info->get('info_page'), zen_get_all_get_params()));
}
zen_product_set_header_response($products_id_current, $product_info);
diff --git a/includes/modules/pages/document_product_info/main_template_vars.php b/includes/modules/pages/document_product_info/main_template_vars.php
index 85b721c23c..8f27117666 100644
--- a/includes/modules/pages/document_product_info/main_template_vars.php
+++ b/includes/modules/pages/document_product_info/main_template_vars.php
@@ -14,11 +14,13 @@
// This should be first line of the script:
$zco_notifier->notify('NOTIFY_MAIN_TEMPLATE_VARS_START_DOCUMENT_PRODUCT_INFO');
- if (!isset($product_info->EOF, $product_info->fields['products_id'], $product_info->fields['products_status']) || (int)$product_info->fields['products_id'] !== (int)$_GET['products_id']) {
- $product_info = zen_get_product_details($_GET['products_id']);
+ $product_info = $product_info ?? new Product($_GET['products_id']);
+
+ if (!isset($product_info->fields['products_id'], $product_info->fields['products_status']) || (int)$product_info->fields['products_id'] !== (int)$_GET['products_id']) {
+ $product_info = new Product($_GET['products_id']);
}
- $product_not_found = $product_info->EOF;
+ $product_not_found = !$product_info->exists();
if (!defined('DISABLED_PRODUCTS_TRIGGER_HTTP200') || DISABLED_PRODUCTS_TRIGGER_HTTP200 !== 'true') {
if (!$product_not_found && $product_info->fields['products_status'] != 1) {
@@ -38,7 +40,7 @@
$products_price = $currencies->display_price($product_info->fields['products_price'], zen_get_tax_rate($product_info->fields['products_tax_class_id']));
- $manufacturers_name= zen_get_products_manufacturers_name((int)$_GET['products_id']);
+ $manufacturers_name = $product_info->fields['manufacturers_name'];
if ($new_price = zen_get_products_special_price($product_info->fields['products_id'])) {
$specials_price = $currencies->display_price($new_price, zen_get_tax_rate($product_info->fields['products_tax_class_id']));
@@ -61,17 +63,17 @@
$reviews = $db->Execute($reviews_query);
- $products_name = $product_info->fields['products_name'];
+ $products_name = $product_info->fields['lang'][$_SESSION['languages_code']]['products_name'];
$products_model = $product_info->fields['products_model'];
// if no common markup tags in description, add line breaks for readability:
- $products_description = (!preg_match('/(
fields['products_description']) ? nl2br($product_info->fields['products_description']) : $product_info->fields['products_description']);
+ $products_description = (!preg_match('/(
fields['lang'][$_SESSION['languages_code']]['products_description']) ? nl2br($product_info->fields['lang'][$_SESSION['languages_code']]['products_description']) : $product_info->fields['lang'][$_SESSION['languages_code']]['products_description']);
$products_image = (($product_not_found || $product_info->fields['products_image'] == '') && PRODUCTS_IMAGE_NO_IMAGE_STATUS == '1') ? PRODUCTS_IMAGE_NO_IMAGE : '';
if ($product_info->fields['products_image'] != '' || PRODUCTS_IMAGE_NO_IMAGE_STATUS != '1') {
$products_image = $product_info->fields['products_image'];
}
- $products_url = $product_info->fields['products_url'];
+ $products_url = $product_info->fields['lang'][$_SESSION['languages_code']]['products_url'];
$products_date_available = $product_info->fields['products_date_available'];
$products_date_added = $product_info->fields['products_date_added'];
$products_manufacturer = $manufacturers_name;
diff --git a/includes/modules/pages/product_free_shipping_info/header_php.php b/includes/modules/pages/product_free_shipping_info/header_php.php
index 472e937e81..4f40bf15a3 100644
--- a/includes/modules/pages/product_free_shipping_info/header_php.php
+++ b/includes/modules/pages/product_free_shipping_info/header_php.php
@@ -13,9 +13,9 @@
require(DIR_WS_MODULES . zen_get_module_directory('require_languages.php'));
-$product_info = zen_get_product_details($products_id_current = (!empty($_GET['products_id']) ? (int)$_GET['products_id'] : 0));
-if (!empty($product_info->fields['type_handler']) && $current_page !== $product_info->fields['type_handler'] . '_info') {
- zen_redirect(zen_href_link($product_info->fields['type_handler'] . '_info', zen_get_all_get_params()));
+$product_info = new Product($products_id_current = (!empty($_GET['products_id']) ? (int)$_GET['products_id'] : 0));
+if ($current_page !== $product_info->get('info_page')) {
+ zen_redirect(zen_href_link($product_info->get('info_page'), zen_get_all_get_params()));
}
zen_product_set_header_response($products_id_current, $product_info);
diff --git a/includes/modules/pages/product_free_shipping_info/main_template_vars.php b/includes/modules/pages/product_free_shipping_info/main_template_vars.php
index dcac2d8c6b..9810e12b11 100644
--- a/includes/modules/pages/product_free_shipping_info/main_template_vars.php
+++ b/includes/modules/pages/product_free_shipping_info/main_template_vars.php
@@ -14,11 +14,13 @@
// This should be first line of the script:
$zco_notifier->notify('NOTIFY_MAIN_TEMPLATE_VARS_START_PRODUCT_FREE_SHIPPING_INFO');
- if (!isset($product_info->EOF, $product_info->fields['products_id'], $product_info->fields['products_status']) || (int)$product_info->fields['products_id'] !== (int)$_GET['products_id']) {
- $product_info = zen_get_product_details($_GET['products_id']);
+ $product_info = $product_info ?? new Product($_GET['products_id']);
+
+ if (!isset($product_info->fields['products_id'], $product_info->fields['products_status']) || (int)$product_info->fields['products_id'] !== (int)$_GET['products_id']) {
+ $product_info = new Product($_GET['products_id']);
}
- $product_not_found = $product_info->EOF;
+ $product_not_found = !$product_info->exists();
if (!defined('DISABLED_PRODUCTS_TRIGGER_HTTP200') || DISABLED_PRODUCTS_TRIGGER_HTTP200 !== 'true') {
if (!$product_not_found && $product_info->fields['products_status'] != 1) {
@@ -38,7 +40,7 @@
$products_price = $currencies->display_price($product_info->fields['products_price'], zen_get_tax_rate($product_info->fields['products_tax_class_id']));
- $manufacturers_name= zen_get_products_manufacturers_name((int)$_GET['products_id']);
+ $manufacturers_name = $product_info->fields['manufacturers_name'];
if ($new_price = zen_get_products_special_price($product_info->fields['products_id'])) {
$specials_price = $currencies->display_price($new_price, zen_get_tax_rate($product_info->fields['products_tax_class_id']));
@@ -61,17 +63,17 @@
$reviews = $db->Execute($reviews_query);
- $products_name = $product_info->fields['products_name'];
+ $products_name = $product_info->fields['lang'][$_SESSION['languages_code']]['products_name'];
$products_model = $product_info->fields['products_model'];
// if no common markup tags in description, add line breaks for readability:
- $products_description = (!preg_match('/(
fields['products_description']) ? nl2br($product_info->fields['products_description']) : $product_info->fields['products_description']);
+ $products_description = (!preg_match('/(
fields['lang'][$_SESSION['languages_code']]['products_description']) ? nl2br($product_info->fields['lang'][$_SESSION['languages_code']]['products_description']) : $product_info->fields['lang'][$_SESSION['languages_code']]['products_description']);
$products_image = (($product_not_found || $product_info->fields['products_image'] == '') && PRODUCTS_IMAGE_NO_IMAGE_STATUS == '1') ? PRODUCTS_IMAGE_NO_IMAGE : '';
if ($product_info->fields['products_image'] != '' || PRODUCTS_IMAGE_NO_IMAGE_STATUS != '1') {
$products_image = $product_info->fields['products_image'];
}
- $products_url = $product_info->fields['products_url'];
+ $products_url = $product_info->fields['lang'][$_SESSION['languages_code']]['products_url'];
$products_date_available = $product_info->fields['products_date_available'];
$products_date_added = $product_info->fields['products_date_added'];
$products_manufacturer = $manufacturers_name;
diff --git a/includes/modules/pages/product_info/header_php.php b/includes/modules/pages/product_info/header_php.php
index eb94317c9b..50ab0ca018 100644
--- a/includes/modules/pages/product_info/header_php.php
+++ b/includes/modules/pages/product_info/header_php.php
@@ -13,9 +13,9 @@
require(DIR_WS_MODULES . zen_get_module_directory('require_languages.php'));
-$product_info = zen_get_product_details($products_id_current = (!empty($_GET['products_id']) ? (int)$_GET['products_id'] : 0));
-if (!empty($product_info->fields['type_handler']) && $current_page !== $product_info->fields['type_handler'] . '_info') {
- zen_redirect(zen_href_link($product_info->fields['type_handler'] . '_info', zen_get_all_get_params()));
+$product_info = new Product($products_id_current = (!empty($_GET['products_id']) ? (int)$_GET['products_id'] : 0));
+if ($current_page !== $product_info->get('info_page')) {
+ zen_redirect(zen_href_link($product_info->get('info_page'), zen_get_all_get_params()));
}
zen_product_set_header_response($products_id_current, $product_info);
diff --git a/includes/modules/pages/product_info/main_template_vars.php b/includes/modules/pages/product_info/main_template_vars.php
index 7a88542216..9e5da75829 100644
--- a/includes/modules/pages/product_info/main_template_vars.php
+++ b/includes/modules/pages/product_info/main_template_vars.php
@@ -14,11 +14,13 @@
// This should be first line of the script:
$zco_notifier->notify('NOTIFY_MAIN_TEMPLATE_VARS_START_PRODUCT_INFO');
- if (!isset($product_info->EOF, $product_info->fields['products_id'], $product_info->fields['products_status']) || (int)$product_info->fields['products_id'] !== (int)$_GET['products_id']) {
- $product_info = zen_get_product_details($_GET['products_id']);
+ $product_info = $product_info ?? new Product($_GET['products_id']);
+
+ if (!isset($product_info->fields['products_id'], $product_info->fields['products_status']) || (int)$product_info->fields['products_id'] !== (int)$_GET['products_id']) {
+ $product_info = new Product($_GET['products_id']);
}
- $product_not_found = $product_info->EOF;
+ $product_not_found = !$product_info->exists();
if (!defined('DISABLED_PRODUCTS_TRIGGER_HTTP200') || DISABLED_PRODUCTS_TRIGGER_HTTP200 !== 'true') {
if (!$product_not_found && $product_info->fields['products_status'] != 1) {
@@ -38,7 +40,7 @@
$products_price = $currencies->display_price($product_info->fields['products_price'], zen_get_tax_rate($product_info->fields['products_tax_class_id']));
- $manufacturers_name = zen_get_products_manufacturers_name((int)$_GET['products_id']);
+ $manufacturers_name = $product_info->fields['manufacturers_name'];
if ($new_price = zen_get_products_special_price($product_info->fields['products_id'])) {
$specials_price = $currencies->display_price($new_price, zen_get_tax_rate($product_info->fields['products_tax_class_id']));
@@ -53,25 +55,25 @@
$review_status = " AND r.status = 1";
$reviews_query = "SELECT count(*) AS count FROM " . TABLE_REVIEWS . " r, "
- . TABLE_REVIEWS_DESCRIPTION . " rd
+ . TABLE_REVIEWS_DESCRIPTION . " rd
WHERE r.products_id = " . (int)$_GET['products_id'] . "
AND r.reviews_id = rd.reviews_id
AND rd.languages_id = " . (int)$_SESSION['languages_id'] .
- $review_status;
+ $review_status;
$reviews = $db->Execute($reviews_query);
- $products_name = $product_info->fields['products_name'];
+ $products_name = $product_info->fields['lang'][$_SESSION['languages_code']]['products_name'];
$products_model = $product_info->fields['products_model'];
// if no common markup tags in description, add line breaks for readability:
- $products_description = (!preg_match('/(
fields['products_description']) ? nl2br($product_info->fields['products_description']) : $product_info->fields['products_description']);
+ $products_description = (!preg_match('/(
fields['lang'][$_SESSION['languages_code']]['products_description']) ? nl2br($product_info->fields['lang'][$_SESSION['languages_code']]['products_description']) : $product_info->fields['lang'][$_SESSION['languages_code']]['products_description']);
$products_image = (($product_not_found || $product_info->fields['products_image'] == '') && PRODUCTS_IMAGE_NO_IMAGE_STATUS == '1') ? PRODUCTS_IMAGE_NO_IMAGE : '';
if ($product_info->fields['products_image'] != '' || PRODUCTS_IMAGE_NO_IMAGE_STATUS != '1') {
$products_image = $product_info->fields['products_image'];
}
- $products_url = $product_info->fields['products_url'];
+ $products_url = $product_info->fields['lang'][$_SESSION['languages_code']]['products_url'];
$products_date_available = $product_info->fields['products_date_available'];
$products_date_added = $product_info->fields['products_date_added'];
$products_manufacturer = $manufacturers_name;
diff --git a/includes/modules/pages/product_music_info/header_php.php b/includes/modules/pages/product_music_info/header_php.php
index 6ba96d9106..c1828a633b 100644
--- a/includes/modules/pages/product_music_info/header_php.php
+++ b/includes/modules/pages/product_music_info/header_php.php
@@ -13,9 +13,9 @@
require(DIR_WS_MODULES . zen_get_module_directory('require_languages.php'));
-$product_info = zen_get_product_details($products_id_current = (!empty($_GET['products_id']) ? (int)$_GET['products_id'] : 0));
-if (!empty($product_info->fields['type_handler']) && $current_page !== $product_info->fields['type_handler'] . '_info') {
- zen_redirect(zen_href_link($product_info->fields['type_handler'] . '_info', zen_get_all_get_params()));
+$product_info = new Product($products_id_current = (!empty($_GET['products_id']) ? (int)$_GET['products_id'] : 0));
+if ($current_page !== $product_info->get('info_page')) {
+ zen_redirect(zen_href_link($product_info->get('info_page'), zen_get_all_get_params()));
}
zen_product_set_header_response($products_id_current, $product_info);
diff --git a/includes/modules/pages/product_music_info/main_template_vars.php b/includes/modules/pages/product_music_info/main_template_vars.php
index 4d4ee8392b..499f26ab18 100644
--- a/includes/modules/pages/product_music_info/main_template_vars.php
+++ b/includes/modules/pages/product_music_info/main_template_vars.php
@@ -14,11 +14,13 @@
// This should be first line of the script:
$zco_notifier->notify('NOTIFY_MAIN_TEMPLATE_VARS_START_PRODUCT_MUSIC_INFO');
- if (!isset($product_info->EOF, $product_info->fields['products_id'], $product_info->fields['products_status']) || (int)$product_info->fields['products_id'] !== (int)$_GET['products_id']) {
- $product_info = zen_get_product_details($_GET['products_id']);
+ $product_info = $product_info ?? new Product($_GET['products_id']);
+
+ if (!isset($product_info->fields['products_id'], $product_info->fields['products_status']) || (int)$product_info->fields['products_id'] !== (int)$_GET['products_id']) {
+ $product_info = new Product($_GET['products_id']);
}
- $product_not_found = $product_info->EOF;
+ $product_not_found = !$product_info->exists();
if (!defined('DISABLED_PRODUCTS_TRIGGER_HTTP200') || DISABLED_PRODUCTS_TRIGGER_HTTP200 !== 'true') {
if (!$product_not_found && $product_info->fields['products_status'] != 1) {
@@ -38,7 +40,7 @@
$products_price = $currencies->display_price($product_info->fields['products_price'], zen_get_tax_rate($product_info->fields['products_tax_class_id']));
- $manufacturers_name = zen_get_products_manufacturers_name((int)$_GET['products_id']);
+ $manufacturers_name = $product_info->fields['manufacturers_name'];
if ($new_price = zen_get_products_special_price($product_info->fields['products_id'])) {
$specials_price = $currencies->display_price($new_price, zen_get_tax_rate($product_info->fields['products_tax_class_id']));
@@ -61,17 +63,17 @@
$reviews = $db->Execute($reviews_query);
- $products_name = $product_info->fields['products_name'];
+ $products_name = $product_info->fields['lang'][$_SESSION['languages_code']]['products_name'];
$products_model = $product_info->fields['products_model'];
// if no common markup tags in description, add line breaks for readability:
- $products_description = (!preg_match('/(
fields['products_description']) ? nl2br($product_info->fields['products_description']) : $product_info->fields['products_description']);
+ $products_description = (!preg_match('/(
fields['lang'][$_SESSION['languages_code']]['products_description']) ? nl2br($product_info->fields['lang'][$_SESSION['languages_code']]['products_description']) : $product_info->fields['lang'][$_SESSION['languages_code']]['products_description']);
$products_image = (($product_not_found || $product_info->fields['products_image'] == '') && PRODUCTS_IMAGE_NO_IMAGE_STATUS == '1') ? PRODUCTS_IMAGE_NO_IMAGE : '';
if ($product_info->fields['products_image'] != '' || PRODUCTS_IMAGE_NO_IMAGE_STATUS != '1') {
$products_image = $product_info->fields['products_image'];
}
- $products_url = $product_info->fields['products_url'];
+ $products_url = $product_info->fields['lang'][$_SESSION['languages_code']]['products_url'];
$products_date_available = $product_info->fields['products_date_available'];
$products_date_added = $product_info->fields['products_date_added'];
$products_manufacturer = $manufacturers_name;
diff --git a/includes/modules/product_listing.php b/includes/modules/product_listing.php
index 57305ce680..7d63d188aa 100644
--- a/includes/modules/product_listing.php
+++ b/includes/modules/product_listing.php
@@ -129,17 +129,16 @@
// Retrieve all records into an array to allow for sorting and insertion of additional data if needed
$records = [];
foreach ($listing as $record) {
+ $product_info = (new Product($record['products_id']))->getDataForLanguage((int)$_SESSION['languages_id']) ?? [];
$category_id = !empty($record['categories_id']) ? $record['categories_id'] : $record['master_categories_id'];
$parent_category_name = trim(zen_get_categories_parent_name($category_id));
$category_name = trim(zen_get_category_name($category_id, (int)$_SESSION['languages_id']));
- $product_details = zen_get_product_details($record['products_id']);
+
$records[] = array_merge($record,
[
'parent_category_name' => (!empty($parent_category_name)) ? $parent_category_name : $category_name,
'category_name' => $category_name,
-// 'master_categories_id' => $record['master_categories_id'],
-// 'products_sort_order' => $record['products_sort_order'],
- ], $product_details->fields ?? []);
+ ], $product_info);
}
if (!empty($_GET['keyword'])) $skip_sort = true;
@@ -219,7 +218,7 @@
$listing_product_name = zen_get_products_name((int)$record['products_id']);
$listing_description = '';
if ((int)PRODUCT_LIST_DESCRIPTION > 0) {
- $listing_description = zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($record['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION);
+ $listing_description = zen_trunc_string(zen_clean_html(stripslashes($record['products_description'])), PRODUCT_LIST_DESCRIPTION);
}
$listing_model = $record['products_model'] ?? '';
$listing_mfg_name = $record['manufacturers_name'] ?? '';
diff --git a/includes/modules/responsive_classic/product_listing.php b/includes/modules/responsive_classic/product_listing.php
index 1739515725..41914aef9a 100644
--- a/includes/modules/responsive_classic/product_listing.php
+++ b/includes/modules/responsive_classic/product_listing.php
@@ -129,17 +129,16 @@
// Retrieve all records into an array to allow for sorting and insertion of additional data if needed
$records = [];
foreach ($listing as $record) {
+ $product_info = (new Product($record['products_id']))->getDataForLanguage((int)$_SESSION['languages_id']) ?? [];
$category_id = !empty($record['categories_id']) ? $record['categories_id'] : $record['master_categories_id'];
$parent_category_name = trim(zen_get_categories_parent_name($category_id));
$category_name = trim(zen_get_category_name($category_id, (int)$_SESSION['languages_id']));
+
$records[] = array_merge($record,
[
'parent_category_name' => (!empty($parent_category_name)) ? $parent_category_name : $category_name,
'category_name' => $category_name,
-// 'products_name' => $record['products_name'],
-// 'master_categories_id' => $record['master_categories_id'],
-// 'products_sort_order' => $record['products_sort_order'],
- ]);
+ ], $product_info);
}
if (!empty($_GET['keyword'])) $skip_sort = true;
@@ -215,7 +214,7 @@
$listing_product_name = $record['products_name'] ?? '';
$listing_description = '';
if ((int)PRODUCT_LIST_DESCRIPTION > 0) {
- $listing_description = zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($record['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION);
+ $listing_description = zen_trunc_string(zen_clean_html(stripslashes($record['products_description'])), PRODUCT_LIST_DESCRIPTION);
$lc_text .= '' . $listing_description . '
';
}
$listing_model = $record['products_model'] ?? '';
diff --git a/includes/modules/sideboxes/best_sellers.php b/includes/modules/sideboxes/best_sellers.php
index 2da886642f..0051a967e9 100644
--- a/includes/modules/sideboxes/best_sellers.php
+++ b/includes/modules/sideboxes/best_sellers.php
@@ -38,6 +38,8 @@
if ($best_sellers->RecordCount() >= MIN_DISPLAY_BESTSELLERS) {
$bestsellers_list = [];
foreach ($best_sellers as $bestseller) {
+ $product_info = (new Product($bestseller['products_id']))->withDefaultLanguage();
+ $bestseller = array_merge($bestseller, $product_info->getData());
$best_products_id = $bestseller['products_id'];
$bestsellers_list[] = [
'id' => $best_products_id,
diff --git a/includes/modules/specials_index.php b/includes/modules/specials_index.php
index 4e7ef618bc..335e66eaae 100644
--- a/includes/modules/specials_index.php
+++ b/includes/modules/specials_index.php
@@ -1,4 +1,5 @@
0 && empty($_GET['filter_id'])) || !empty($_GET['music_genre_id']) || !empty($_GET['record_company_id'])) || empty($new_products_category_id) ) {
- $specials_index_query = "SELECT p.products_id, p.products_image, pd.products_name, p.master_categories_id
+if ((($manufacturers_id > 0 && empty($_GET['filter_id'])) || !empty($_GET['music_genre_id']) || !empty($_GET['record_company_id'])) || empty($new_products_category_id)) {
+ $specials_index_query = "SELECT p.products_id, p.products_image, pd.products_name, p.master_categories_id
FROM (" . TABLE_PRODUCTS . " p
LEFT JOIN " . TABLE_SPECIALS . " s ON p.products_id = s.products_id
LEFT JOIN " . TABLE_PRODUCTS_DESCRIPTION . " pd ON p.products_id = pd.products_id )
@@ -27,16 +28,16 @@
AND p.products_status = 1 AND s.status = 1
AND pd.language_id = " . (int)$_SESSION['languages_id'];
} else {
- // get all products and cPaths in this subcat tree
- $productsInCategory = zen_get_categories_products_list( (($manufacturers_id > 0 && !empty($_GET['filter_id'])) ? zen_get_generated_category_path_rev($_GET['filter_id']) : $cPath), false, true, 0, $display_limit);
+ // get all products and cPaths in this subcat tree
+ $productsInCategory = zen_get_categories_products_list((($manufacturers_id > 0 && !empty($_GET['filter_id'])) ? zen_get_generated_category_path_rev($_GET['filter_id']) : $cPath), false, true, 0, $display_limit);
- if (is_array($productsInCategory) && sizeof($productsInCategory) > 0) {
- // build products-list string to insert into SQL query
- foreach($productsInCategory as $key => $value) {
- $list_of_products .= $key . ', ';
- }
- $list_of_products = substr($list_of_products, 0, -2); // remove trailing comma
- $specials_index_query = "SELECT DISTINCT p.products_id, p.products_image, pd.products_name, p.master_categories_id
+ if (is_array($productsInCategory) && sizeof($productsInCategory) > 0) {
+ // build products-list string to insert into SQL query
+ foreach ($productsInCategory as $key => $value) {
+ $list_of_products .= $key . ', ';
+ }
+ $list_of_products = substr($list_of_products, 0, -2); // remove trailing comma
+ $specials_index_query = "SELECT DISTINCT p.products_id, p.products_image, pd.products_name, p.master_categories_id
FROM (" . TABLE_PRODUCTS . " p
LEFT JOIN " . TABLE_SPECIALS . " s ON p.products_id = s.products_id
LEFT JOIN " . TABLE_PRODUCTS_DESCRIPTION . " pd ON p.products_id = pd.products_id )
@@ -45,46 +46,64 @@
AND p.products_status = 1 AND s.status = 1
AND pd.language_id = " . (int)$_SESSION['languages_id'] . "
AND p.products_id in (" . $list_of_products . ")";
- }
+ }
+}
+if ($specials_index_query !== '') {
+ $specials_index = $db->ExecuteRandomMulti($specials_index_query, MAX_DISPLAY_SPECIAL_PRODUCTS_INDEX);
}
-if ($specials_index_query != '') $specials_index = $db->ExecuteRandomMulti($specials_index_query, MAX_DISPLAY_SPECIAL_PRODUCTS_INDEX);
$row = 0;
$col = 0;
-$list_box_contents = array();
+$list_box_contents = [];
$title = '';
-$num_products_count = ($specials_index_query == '') ? 0 : $specials_index->RecordCount();
+$num_products_count = ($specials_index_query === '') ? 0 : $specials_index->RecordCount();
// show only when 1 or more
if ($num_products_count > 0) {
- if ($num_products_count < SHOW_PRODUCT_INFO_COLUMNS_SPECIALS_PRODUCTS || SHOW_PRODUCT_INFO_COLUMNS_SPECIALS_PRODUCTS == 0 ) {
- $col_width = floor(100/$num_products_count);
- } else {
- $col_width = floor(100/SHOW_PRODUCT_INFO_COLUMNS_SPECIALS_PRODUCTS);
- }
+ if ($num_products_count < SHOW_PRODUCT_INFO_COLUMNS_SPECIALS_PRODUCTS || SHOW_PRODUCT_INFO_COLUMNS_SPECIALS_PRODUCTS == 0) {
+ $col_width = floor(100 / $num_products_count);
+ } else {
+ $col_width = floor(100 / SHOW_PRODUCT_INFO_COLUMNS_SPECIALS_PRODUCTS);
+ }
+
+ $list_box_contents = [];
+ while (!$specials_index->EOF) {
+ $product_info = new Product($specials_index->fields['products_id']);
+ $data = array_merge($specials_index->fields, $product_info->getDataForLanguage());
- $list_box_contents = array();
- while (!$specials_index->EOF) {
- $products_price = zen_get_products_display_price($specials_index->fields['products_id']);
- if (!isset($productsInCategory[$specials_index->fields['products_id']])) $productsInCategory[$specials_index->fields['products_id']] = zen_get_generated_category_path_rev($specials_index->fields['master_categories_id']);
+ $products_price = zen_get_products_display_price($data['products_id']);
+ if (!isset($productsInCategory[$data['products_id']])) {
+ $productsInCategory[$data['products_id']] = zen_get_generated_category_path_rev($data['master_categories_id']);
+ }
- $zco_notifier->notify('NOTIFY_MODULES_SPECIALS_INDEX_B4_LIST_BOX', array(), $specials_index->fields, $products_price);
+ $zco_notifier->notify('NOTIFY_MODULES_SPECIALS_INDEX_B4_LIST_BOX', [], $data, $products_price);
- $specials_index->fields['products_name'] = zen_get_products_name($specials_index->fields['products_id']);
- $list_box_contents[$row][$col] = array('params' => 'class="centerBoxContentsSpecials centeredContent back"' . ' ' . 'style="width:' . $col_width . '%;"',
- 'text' => (($specials_index->fields['products_image'] == '' and PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0) ? '' : '' . zen_image(DIR_WS_IMAGES . $specials_index->fields['products_image'], $specials_index->fields['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '
') . '' . $specials_index->fields['products_name'] . '
' . $products_price);
+ $data['products_name'] = zen_get_products_name($data['products_id']);
+ $list_box_contents[$row][$col] = [
+ 'params' => 'class="centerBoxContentsSpecials centeredContent back"' . ' ' . 'style="width:' . $col_width . '%;"',
+ 'text' => (($data['products_image'] === '' && PRODUCTS_IMAGE_NO_IMAGE_STATUS == 0)
+ ? ''
+ : ''
+ . zen_image(DIR_WS_IMAGES . $data['products_image'], $data['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT)
+ . '
')
+ . '' . $data['products_name']
+ . '
' . $products_price,
+ ];
- $col ++;
- if ($col > (SHOW_PRODUCT_INFO_COLUMNS_SPECIALS_PRODUCTS - 1)) {
- $col = 0;
- $row ++;
+ $col++;
+ if ($col > (SHOW_PRODUCT_INFO_COLUMNS_SPECIALS_PRODUCTS - 1)) {
+ $col = 0;
+ $row++;
+ }
+ $specials_index->MoveNextRandom();
}
- $specials_index->MoveNextRandom();
- }
- if ($specials_index->RecordCount() > 0) {
- $title = '' . sprintf(TABLE_HEADING_SPECIALS_INDEX, $zcDate->output('%B')) . '
';
- $zc_show_specials = true;
- }
+ if ($specials_index->RecordCount() > 0) {
+ $title = '' . sprintf(TABLE_HEADING_SPECIALS_INDEX, $zcDate->output('%B')) . '
';
+ $zc_show_specials = true;
+ }
}
diff --git a/includes/modules/upcoming_products.php b/includes/modules/upcoming_products.php
index f86aa7cf83..f6a9329d88 100644
--- a/includes/modules/upcoming_products.php
+++ b/includes/modules/upcoming_products.php
@@ -1,4 +1,5 @@
0 && empty($_GET['filter_id'])) || !empty($_GET['music_genre_id']) || !empty($_GET['record_company_id'])) || empty($new_products_category_id) ) {
- $expected_query = "SELECT p.products_id, pd.products_name, products_date_available AS date_expected, p.master_categories_id
- FROM " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
- WHERE p.products_id = pd.products_id
- AND p.products_status = 1
- AND pd.language_id = " . (int)$_SESSION['languages_id'] .
- $display_limit .
- $limit_clause;
+if ((($manufacturers_id > 0 && empty($_GET['filter_id'])) || !empty($_GET['music_genre_id']) || !empty($_GET['record_company_id'])) || empty($new_products_category_id)) {
+ $sql = "SELECT p.products_id, pd.products_name, products_date_available AS date_expected, p.master_categories_id
+ FROM " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
+ WHERE p.products_id = pd.products_id
+ AND p.products_status = 1
+ AND pd.language_id = " . (int)$_SESSION['languages_id'] .
+ $display_limit .
+ $limit_clause;
} else {
- // get all products and cPaths in this subcat tree
- $productsInCategory = zen_get_categories_products_list( (($manufacturers_id > 0 && !empty($_GET['filter_id'])) ? zen_get_generated_category_path_rev($_GET['filter_id']) : $cPath), false, true, 0, $display_limit);
+ // get all products and cPaths in this subcat tree
+ $productsInCategory = zen_get_categories_products_list((($manufacturers_id > 0 && !empty($_GET['filter_id'])) ? zen_get_generated_category_path_rev($_GET['filter_id']) : $cPath), false, true, 0, $display_limit);
+
+ if (is_array($productsInCategory) && count($productsInCategory) > 0) {
+ // build products-list string to insert into SQL query
+ foreach ($productsInCategory as $key => $value) {
+ $list_of_products .= $key . ', ';
+ }
+ $list_of_products = substr($list_of_products, 0, -2); // remove trailing comma
- if (is_array($productsInCategory) && sizeof($productsInCategory) > 0) {
- // build products-list string to insert into SQL query
- foreach($productsInCategory as $key => $value) {
- $list_of_products .= $key . ', ';
+ $sql = "SELECT p.products_id, pd.products_name, products_date_available AS date_expected, p.master_categories_id
+ FROM " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
+ WHERE p.products_id = pd.products_id
+ AND p.products_id IN (" . $list_of_products . ")
+ AND p.products_status = 1
+ AND pd.language_id = " . (int)$_SESSION['languages_id'] .
+ $display_limit .
+ $limit_clause;
}
- $list_of_products = substr($list_of_products, 0, -2); // remove trailing comma
-
- $expected_query = "SELECT p.products_id, pd.products_name, products_date_available AS date_expected, p.master_categories_id
- FROM " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
- WHERE p.products_id = pd.products_id
- AND p.products_id IN (" . $list_of_products . ")
- AND p.products_status = 1
- AND pd.language_id = " . (int)$_SESSION['languages_id'] .
- $display_limit .
- $limit_clause;
- }
}
-if ($expected_query != '') $expected = $db->Execute($expected_query);
-if ($expected_query != '' && $expected->RecordCount() > 0) {
- foreach ($expected as $expect) {
- if (!isset($productsInCategory[$expect['products_id']])) $productsInCategory[$expect['products_id']] = zen_get_generated_category_path_rev($expect['master_categories_id']);
- $expectedItems[] = $expect;
- }
- require($template->get_template_dir('tpl_modules_upcoming_products.php', DIR_WS_TEMPLATE, $current_page_base,'templates'). '/' . 'tpl_modules_upcoming_products.php');
+if ($sql !== '') {
+ $expected = $db->Execute($sql);
+}
+if ($sql !== '' && $expected->RecordCount() > 0) {
+ foreach ($expected as $expect) {
+ if (!isset($productsInCategory[$expect['products_id']])) {
+ $productsInCategory[$expect['products_id']] = zen_get_generated_category_path_rev($expect['master_categories_id']);
+ }
+ $expectedItems[] = array_merge($expect, (new Product($expect['products_id']))->getDataForLanguage());
+ }
+ require $template->get_template_dir('tpl_modules_upcoming_products.php', DIR_WS_TEMPLATE, $current_page_base, 'templates') . '/' . 'tpl_modules_upcoming_products.php';
}
diff --git a/includes/psr4Autoload.php b/includes/psr4Autoload.php
index aca60ffae5..e12227eda6 100644
--- a/includes/psr4Autoload.php
+++ b/includes/psr4Autoload.php
@@ -25,6 +25,7 @@
$psr4Autoloader->addPrefix('Zencart\Paginator', DIR_FS_ADMIN . DIR_WS_CLASSES);
}
$psr4Autoloader->setClassFile('language', DIR_FS_CATALOG . DIR_WS_CLASSES . 'language.php' );
+$psr4Autoloader->setClassFile('Product', DIR_FS_CATALOG . DIR_WS_CLASSES . 'Product.php' );
$psr4Autoloader->setClassFile('Settings', DIR_FS_CATALOG . DIR_WS_CLASSES . 'Settings.php' );
$psr4Autoloader->setClassFile('TemplateSettings', DIR_FS_CATALOG . DIR_WS_CLASSES . 'TemplateSettings.php' );
$psr4Autoloader->setClassFile('ZenShipping', DIR_FS_CATALOG . DIR_WS_CLASSES . 'ZenShipping.php');
diff --git a/includes/templates/responsive_classic/sideboxes/tpl_reviews_random.php b/includes/templates/responsive_classic/sideboxes/tpl_reviews_random.php
index ed987e9c9f..b478132bad 100644
--- a/includes/templates/responsive_classic/sideboxes/tpl_reviews_random.php
+++ b/includes/templates/responsive_classic/sideboxes/tpl_reviews_random.php
@@ -7,12 +7,16 @@
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version $Id: DrByte 2020 Dec 25 Modified in v1.5.8-alpha $
*/
- $content = "";
- $review_box_counter = 0;
- while (!$random_review_sidebox_product->EOF) {
+$content = "";
+$review_box_counter = 0;
+while (!$random_review_sidebox_product->EOF) {
$review_box_counter++;
$content .= '';
- $content .= '
' . zen_image(DIR_WS_IMAGES . $random_review_sidebox_product->fields['products_image'], $random_review_sidebox_product->fields['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '
' . nl2br(zen_trunc_string(zen_output_string_protected(stripslashes($random_review_sidebox_product->fields['reviews_text'])), 60)) . '' . zen_image(DIR_WS_TEMPLATE_IMAGES . 'stars_' . $random_review_sidebox_product->fields['reviews_rating'] . '.png' , sprintf(BOX_REVIEWS_TEXT_OF_5_STARS, $random_review_sidebox_product->fields['reviews_rating']));
+ $content .= '
'
+ . zen_image(DIR_WS_IMAGES . $random_review_sidebox_product->fields['products_image'], zen_get_products_name($random_review_sidebox_product->fields['products_id']), SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT)
+ . '
' . nl2br(zen_trunc_string(zen_output_string_protected(stripslashes($random_review_sidebox_product->fields['reviews_text'])), 60))
+ . ''
+ . zen_image(DIR_WS_TEMPLATE_IMAGES . 'stars_' . $random_review_sidebox_product->fields['reviews_rating'] . '.png', sprintf(BOX_REVIEWS_TEXT_OF_5_STARS, $random_review_sidebox_product->fields['reviews_rating']));
$content .= '
';
$random_review_sidebox_product->MoveNextRandom();
- }
+}
diff --git a/includes/templates/template_default/sideboxes/tpl_featured.php b/includes/templates/template_default/sideboxes/tpl_featured.php
index 0cad6f550d..5792ca08fe 100644
--- a/includes/templates/template_default/sideboxes/tpl_featured.php
+++ b/includes/templates/template_default/sideboxes/tpl_featured.php
@@ -1,4 +1,5 @@
';
- $featured_box_counter = 0;
- while (!$random_featured_product->EOF) {
+$content = "";
+$content .= '';
+$featured_box_counter = 0;
+while (!$random_featured_product->EOF) {
+ $data = (new Product($random_featured_product->fields['products_id']))->withDefaultLanguage()->getData();
$featured_box_counter++;
- $featured_box_price = zen_get_products_display_price($random_featured_product->fields['products_id']);
+ $featured_box_price = zen_get_products_display_price($data['products_id']);
$content .= "\n" . '
';
$random_featured_product->MoveNextRandom();
- }
- $content .= '
' . "\n";
+}
+$content .= '' . "\n";
diff --git a/includes/templates/template_default/sideboxes/tpl_reviews_random.php b/includes/templates/template_default/sideboxes/tpl_reviews_random.php
index f5eb98d3f8..ace65db745 100644
--- a/includes/templates/template_default/sideboxes/tpl_reviews_random.php
+++ b/includes/templates/template_default/sideboxes/tpl_reviews_random.php
@@ -7,12 +7,16 @@
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version $Id: DrByte 2020 Dec 25 Modified in v1.5.8-alpha $
*/
- $content = "";
- $review_box_counter = 0;
- while (!$random_review_sidebox_product->EOF) {
+$content = "";
+$review_box_counter = 0;
+while (!$random_review_sidebox_product->EOF) {
$review_box_counter++;
$content .= '';
- $content .= '
' . zen_image(DIR_WS_IMAGES . $random_review_sidebox_product->fields['products_image'], $random_review_sidebox_product->fields['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '
' . nl2br(zen_trunc_string(zen_output_string_protected(stripslashes($random_review_sidebox_product->fields['reviews_text'])), 60)) . '' . zen_image(DIR_WS_TEMPLATE_IMAGES . 'stars_' . $random_review_sidebox_product->fields['reviews_rating'] . '.gif' , sprintf(BOX_REVIEWS_TEXT_OF_5_STARS, $random_review_sidebox_product->fields['reviews_rating']));
+ $content .= '
'
+ . zen_image(DIR_WS_IMAGES . $random_review_sidebox_product->fields['products_image'], zen_get_products_name($random_review_sidebox_product->fields['products_id']), SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT)
+ . '
' . nl2br(zen_trunc_string(zen_output_string_protected(stripslashes($random_review_sidebox_product->fields['reviews_text'])), 60))
+ . ''
+ . zen_image(DIR_WS_TEMPLATE_IMAGES . 'stars_' . $random_review_sidebox_product->fields['reviews_rating'] . '.gif', sprintf(BOX_REVIEWS_TEXT_OF_5_STARS, $random_review_sidebox_product->fields['reviews_rating']));
$content .= '
';
$random_review_sidebox_product->MoveNextRandom();
- }
+}
diff --git a/includes/templates/template_default/sideboxes/tpl_specials.php b/includes/templates/template_default/sideboxes/tpl_specials.php
index 659fe82954..514a9d717a 100644
--- a/includes/templates/template_default/sideboxes/tpl_specials.php
+++ b/includes/templates/template_default/sideboxes/tpl_specials.php
@@ -1,4 +1,5 @@
';
- $specials_box_counter = 0;
- while (!$random_specials_sidebox_product->EOF) {
+$content = "";
+$content .= '';
+$specials_box_counter = 0;
+while (!$random_specials_sidebox_product->EOF) {
+ $data = array_merge($random_specials_sidebox_product->fields, (new Product($random_specials_sidebox_product->fields['products_id']))->withDefaultLanguage()->getData());
$specials_box_counter++;
- $specials_box_price = zen_get_products_display_price($random_specials_sidebox_product->fields['products_id']);
+ $specials_box_price = zen_get_products_display_price($data['products_id']);
$content .= "\n" . '
';
$random_specials_sidebox_product->MoveNextRandom();
- }
- $content .= '
' . "\n";
+}
+$content .= '' . "\n";
diff --git a/includes/templates/template_default/sideboxes/tpl_whats_new.php b/includes/templates/template_default/sideboxes/tpl_whats_new.php
index 6a077ccea3..3c39bd28f0 100644
--- a/includes/templates/template_default/sideboxes/tpl_whats_new.php
+++ b/includes/templates/template_default/sideboxes/tpl_whats_new.php
@@ -1,4 +1,5 @@
';
- $whats_new_box_counter = 0;
- while (!$random_whats_new_sidebox_product->EOF) {
+$content = "";
+$content .= '';
+$whats_new_box_counter = 0;
+while (!$random_whats_new_sidebox_product->EOF) {
+ $data = (new Product($random_whats_new_sidebox_product->fields['products_id']))->withDefaultLanguage()->getData();
+
$whats_new_box_counter++;
- $whats_new_price = zen_get_products_display_price($random_whats_new_sidebox_product->fields['products_id']);
+ $whats_new_price = zen_get_products_display_price($data['products_id']);
$content .= "\n" . '
';
$random_whats_new_sidebox_product->MoveNextRandom();
- }
- $content .= '
' . "\n";
+}
+$content .= '' . "\n";