hakeryk2 Posted January 11, 2018 Posted January 11, 2018 Hello, Is there is any function that is checking is product is discounted but instead of default one Product::isDiscounted((int)$product['id_product']) with ability to check if product attribute is discounted instead of whole product? Share this post Link to post Share on other sites More sharing options...
justAman004 Posted July 19, 2021 Posted July 19, 2021 On 1/11/2018 at 3:58 PM, hakeryk2 said: Hello, Is there is any function that is checking is product is discounted but instead of default one Product::isDiscounted((int)$product['id_product']) with ability to check if product attribute is discounted instead of whole product? I have the same question. Anybody..? Share this post Link to post Share on other sites More sharing options...
hakeryk2 Posted July 19, 2021 Posted July 19, 2021 /** * @param $id_product * @param int $quantity * @param Context|null $context * @param null $id_product_attribute * @return bool */ public static function isDiscounted($id_product, $quantity = 1, Context $context = null, $id_product_attribute = null) { if (!$context) { $context = Context::getContext(); } @$id_group = $context->customer->id_default_group; @$cart_quantity = !$context->cart ? 0 : Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue(' SELECT SUM(`quantity`) FROM `'._DB_PREFIX_.'cart_product` WHERE `id_product` = '.(int)$id_product.' AND `id_product_attribute` = '.(int)$id_product_attribute.' AND `id_cart` = '.(int)$context->cart->id ); $quantity = $cart_quantity ? $cart_quantity : $quantity; @$id_currency = (int)$context->currency->id; @$ids = Address::getCountryAndState((int)$context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}); $id_country = $ids['id_country'] ? (int)$ids['id_country'] : (int)Configuration::get('PS_COUNTRY_DEFAULT'); return (bool)SpecificPrice::getSpecificPrice((int)$id_product, $context->shop->id, $id_currency, $id_country, $id_group, $quantity, $id_product_attribute, 0, 0, $quantity); } Well, this is what I ended up with. Put this into Product.php override. Share this post Link to post Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now