[Skip to main content](#vessel-content)

#   Custom Price Based On Contents of Cart

##

- **[slittle](/forum/user/33192-slittle "View slittle's Profile")**
- [![slittle's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/33192-slittle "View slittle's Profile") Topic Author
- [ Offline](/forum/user/33192-slittle)

Less More

- Posts: 8
- Thank you received: 1
-
-

12 years 2 months ago [\#169161](#169161) by [slittle](/forum/user/33192-slittle "View slittle's Profile")  *[Custom Price Based On Contents of Cart](/forum/26-product-category-display/870663-custom-price-based-on-contents-of-cart#169161 "-- HikaShop version -- : 2.3.2 -- Joomla version -- : 3.3.3 -- PHP version -- : 5.4.31  I need Hikashop to display certain price levels (as assigned in the admin area) based on the presence of a particular item in the shopping cart. There is a 'membership fee' to get special (lower) prices on the products in this website I'm working on. I could, of course, handle this with ACLs in the admin area... but that doesn't help with newly arrived customers who don't even have an account yet... Basically, the idea here is if the cart does not contain item 'X' then they see price A (retail)... if the cart DOES contain item 'X' then they see price B (wholesale).  I've been hacking away at the custom price plugin... It gets me CLOSE to what I want... but I'm having some challenges. It would be perfect if I could hack that plugin to do the following: A: Each time it's fired I cycle through the cart and check for X B: If I find X then tell hikashop to use price B otherwise use default  As written the plugin brute-forces a price into the product object... I'd rather tell it to relax it's ACL filters as if the guest user had group Y membership. If this is not possible (or practical) then I could brute-force it - but I still need a way to access the shopping cart from inside the hikashop&#95;product&#95;price&#95;for&#95;quantity&#95;in&#95;cart() function.  Any suggestions?")* was created by *[slittle](/forum/user/33192-slittle "View slittle's Profile")*

-- HikaShop version -- : 2.3.2
-- Joomla version -- : 3.3.3
-- PHP version -- : 5.4.31

I need Hikashop to display certain price levels (as assigned in the admin area) based on the presence of a particular item in the shopping cart. There is a 'membership fee' to get special (lower) prices on the products in this website I'm working on. I could, of course, handle this with ACLs in the admin area... but that doesn't help with newly arrived customers who don't even have an account yet... Basically, the idea here is if the cart does not contain item 'X' then they see price A (retail)... if the cart DOES contain item 'X' then they see price B (wholesale).

I've been hacking away at the custom price plugin... It gets me CLOSE to what I want... but I'm having some challenges. It would be perfect if I could hack that plugin to do the following:
A: Each time it's fired I cycle through the cart and check for X
B: If I find X then tell hikashop to use price B otherwise use default

As written the plugin brute-forces a price into the product object... I'd rather tell it to relax it's ACL filters as if the guest user had group Y membership. If this is not possible (or practical) then I could brute-force it - but I still need a way to access the shopping cart from inside the hikashop_product_price_for_quantity_in_cart() function.

Any suggestions?

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI2LXByb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS84NzA2NjMtY3VzdG9tLXByaWNlLWJhc2VkLW9uLWNvbnRlbnRzLW9mLWNhcnQ/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Jerome](/forum/user/80-jerome "View Jerome's Profile")**
- [![Jerome's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar80.png)](/forum/user/80-jerome "View Jerome's Profile")
- [ Offline](/forum/user/80-jerome)
- HikaShop core developer

Less More

- Posts: 26400
- Thank you received: 4079
-
- [](http://obsi.dev)
-

12 years 2 months ago [\#169240](#169240) by [Jerome](/forum/user/80-jerome "View Jerome's Profile")  Replied by *[Jerome](/forum/user/80-jerome "View Jerome's Profile")* on topic *[Custom Price Based On Contents of Cart](/forum/26-product-category-display/870663-custom-price-based-on-contents-of-cart#169240 "-- HikaShop version -- : 2.3.2 -- Joomla version -- : 3.3.3 -- PHP version -- : 5.4.31  I need Hikashop to display certain price levels (as assigned in the admin area) based on the presence of a particular item in the shopping cart. There is a 'membership fee' to get special (lower) prices on the products in this website I'm working on. I could, of course, handle this with ACLs in the admin area... but that doesn't help with newly arrived customers who don't even have an account yet... Basically, the idea here is if the cart does not contain item 'X' then they see price A (retail)... if the cart DOES contain item 'X' then they see price B (wholesale).  I've been hacking away at the custom price plugin... It gets me CLOSE to what I want... but I'm having some challenges. It would be perfect if I could hack that plugin to do the following: A: Each time it's fired I cycle through the cart and check for X B: If I find X then tell hikashop to use price B otherwise use default  As written the plugin brute-forces a price into the product object... I'd rather tell it to relax it's ACL filters as if the guest user had group Y membership. If this is not possible (or practical) then I could brute-force it - but I still need a way to access the shopping cart from inside the hikashop&#95;product&#95;price&#95;for&#95;quantity&#95;in&#95;cart() function.  Any suggestions?")*

Hi,

Like that I would recommend you to use the plugin "group after purchase" so the user group can change by buying a special product in your store.
But this feature won't work on the same order, because the user group will change after the order ; it will provide you the same feature but in two steps (two orders).

If you want to load the full cart, you can use Code:

$cartClass = hikashop_get('class.cart'); $cart = $cartClass-&gt;loadFullCart();

Instead of the function "hikashop_product_price_for_quantity_in_cart" you can use a classical HikaShop plugin and the trigger "onBeforeCalculateProductPriceForQuantity".
The function give you the product object with his prices and you can modify it like you want.

Regards,

---

Jerome - Obsidev.com
HikaMarket &amp; HikaSerial developer / HikaShop core dev team.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI2LXByb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS84NzA2NjMtY3VzdG9tLXByaWNlLWJhc2VkLW9uLWNvbnRlbnRzLW9mLWNhcnQ/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.058 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
