/** * The getCategoryReduction method * * PATCH: több csoportos MAX logika * * @param integer $id_category * @param integer $id_customer * @param integer $id_group * @return array|false */ public function getCategoryReduction($id_category, $id_customer = null, $id_group = null) { if (!$id_category) { return false; } $use_multi_group = false; $groups = array(); // --- 1) Több csoport figyelembevétele bejelentkezett usernél --- if ($id_customer && Configuration::get('M4CATDISCOUNT_ENABLE_GROUPS')) { $customer = new Customer((int)$id_customer); if (Validate::isLoadedObject($customer)) { $groups = Customer::getGroupsStatic((int)$customer->id); if (!is_array($groups) || empty($groups)) { $groups = array((int)$customer->id_default_group); } $use_multi_group = true; } } if ($use_multi_group) { // MAX logika: az adott kategóriára a user ÖSSZES csoportjára nézzük a kedvezményeket $groups = array_map('intval', $groups); $sql = ' SELECT MAX(`reduction_percent_cache`) AS max_percent, MAX(`reduction_price_cache`) AS max_price FROM `'._DB_PREFIX_.'m4_category_discount` WHERE `id_category` = '.(int)$id_category.' AND `id_group` IN ('.implode(',', $groups).') '; $row = Db::getInstance()->getRow($sql); // nincs találat / nincs kedvezmény if ( !$row || (is_null($row['max_percent']) && is_null($row['max_price'])) ) { return false; } return array( 'reduction_price' => !is_null($row['max_price']) ? (float)$row['max_price'] : null, 'reduction_percent' => !is_null($row['max_percent']) ? (float)$row['max_percent'] : null, ); } // --- 2) Fallback: eredeti 1 csoportos logika (vendég / nincs customer) --- if (!$id_group) { $customer = null; if ($id_customer) { $customer = new Customer((int)$id_customer); } if (Validate::isLoadedObject($customer) && Configuration::get('M4CATDISCOUNT_ENABLE_GROUPS')) { $id_group = (int)$customer->id_default_group; } else { $id_group = (int)Configuration::get('PS_CUSTOMER_GROUP'); } } $result = Db::getInstance()->getRow(' SELECT `reduction_price_cache`, `reduction_percent_cache` FROM `'._DB_PREFIX_.'m4_category_discount` WHERE `id_group` = '.(int)$id_group.' AND `id_category` = '.(int)$id_category); if (!$result) { return false; } return array( 'reduction_price' => isset($result['reduction_price_cache']) ? (float)$result['reduction_price_cache'] : null, 'reduction_percent' => isset($result['reduction_percent_cache']) ? (float)$result['reduction_percent_cache'] : null, ); } Ti Pro Lite Sattelstütze für Carbon Sättel 30,9/350mm, schwarz - Cooolstore B2B
Ti Pro Lite for carbon rails 30,9/350mm, black View larger

Ti Pro Lite Sattelstütze für Carbon Sättel 30,9/350mm, schwarz

806076


Ask a question (0)

Remove from wishlist Add to wishlist

Data sheet

More info

This seatpost convinces not only with its low weight, but also with its look. Seatpost made of high-tech material Scandium 7451 with titanium bolts and a 7075 aluminum seat clamp. Suitable for road bike and MTB.

Question (0)

No questions yet.

Only registered user can ask a question. Login

Download