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

#   Discount in cart based on custom fields

##

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

Less More

- Posts: 14
- Thank you received: 0
-
-

10 years 4 months ago [\#241819](#241819) by [insitevision](/forum/user/35045-insitevision "View insitevision's Profile")  *[Discount in cart based on custom fields](/forum/46-discount-coupon/884859-discount-in-cart-based-on-custom-fields#241819 "-- HikaShop version -- : 2.6.3 -- Joomla version -- : 3.5.1 -- PHP version -- : 7.0.6 -- Browser(s) name and version -- : Firefox 46.0.1  Hi,  A little intoduction:  A client is selling pvc floors. The price for a product is a price per m2. However a package contains for instance 3.62 m2 and he only sells full packages.  I made a custom field for priceperm2, a custom field for packegecontents and a custom field so a client can fill in the surface for which he needs a floor.  On the product page there is a input field where a customer can enter the surface of m2 he needs (for instance 12 m2) and than the amount of packages (3.62 m2 per package) is calculated, so in the cart there will be 4 packages (= 14.48 m2)  This is working fine but now he wants to advertise with the slogan &quot;Every 5th m is for free&quot;. So, in the example above (when surface = 12, price per m2 = 42.95 and package price = 155.48 there should be a (calculated) discount of: ((floor)surface/5 &#42; priceperm2))  My question: How can I implement this so that in the cart there is a (per product) calculated discount that is substracted from the total price as in the attached (photoshopped image)?  Kind regards, Eric Beernink")* was created by *[insitevision](/forum/user/35045-insitevision "View insitevision's Profile")*

-- HikaShop version -- : 2.6.3
-- Joomla version -- : 3.5.1
-- PHP version -- : 7.0.6
-- Browser(s) name and version -- : Firefox 46.0.1

Hi,

A little intoduction:

A client is selling pvc floors. The price for a product is a price per m2. However a package contains for instance 3.62 m2 and he only sells full packages.

I made a custom field for priceperm2, a custom field for packegecontents and a custom field so a client can fill in the surface for which he needs a floor.

On the product page there is a input field where a customer can enter the surface of m2 he needs (for instance 12 m2) and than the amount of packages (3.62 m2 per package) is calculated, so in the cart there will be 4 packages (= 14.48 m2)

This is working fine but now he wants to advertise with the slogan "Every 5th m is for free". So, in the example above (when surface = 12, price per m2 = 42.95 and package price = 155.48 there should be a (calculated) discount of: ((floor)surface/5 * priceperm2))

My question:
How can I implement this so that in the cart there is a (per product) calculated discount that is substracted from the total price as in the attached (photoshopped image)?

Kind regards,
Eric Beernink

- [ ![examplecart.jpg](/forum/attachment/31811) ](/forum/attachment/31811 "examplecart.jpg") [ ](/forum/attachment/31811?download=1 "examplecart.jpg")

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

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86290
- Thank you received: 14268
-
-

10 years 4 months ago [\#241820](#241820) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Discount in cart based on custom fields](/forum/46-discount-coupon/884859-discount-in-cart-based-on-custom-fields#241820 "-- HikaShop version -- : 2.6.3 -- Joomla version -- : 3.5.1 -- PHP version -- : 7.0.6 -- Browser(s) name and version -- : Firefox 46.0.1  Hi,  A little intoduction:  A client is selling pvc floors. The price for a product is a price per m2. However a package contains for instance 3.62 m2 and he only sells full packages.  I made a custom field for priceperm2, a custom field for packegecontents and a custom field so a client can fill in the surface for which he needs a floor.  On the product page there is a input field where a customer can enter the surface of m2 he needs (for instance 12 m2) and than the amount of packages (3.62 m2 per package) is calculated, so in the cart there will be 4 packages (= 14.48 m2)  This is working fine but now he wants to advertise with the slogan &quot;Every 5th m is for free&quot;. So, in the example above (when surface = 12, price per m2 = 42.95 and package price = 155.48 there should be a (calculated) discount of: ((floor)surface/5 &#42; priceperm2))  My question: How can I implement this so that in the cart there is a (per product) calculated discount that is substracted from the total price as in the attached (photoshopped image)?  Kind regards, Eric Beernink")*

Hi,

There is no system to something exactly like that.
Sure, you could edit the file "cart" of the view "checkout" to add such display, but all the totals would have to be recalculated everywhere.
I would rather recommend to use the additional system which allows you to add extra rows between the sub total and the shipping fee rows everywhere with the system automatically recalculating the total based on what you give in the plugin.
That's close to the display you want and it will be a long term solution.
Here is a example plugin which uses this system: [ www.hikashop.com/forum/taxes/873285-fix-tax-import.html#190511](http://www.hikashop.com/forum/taxes/873285-fix-tax-import.html#190511)

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQ2LWRpc2NvdW50LWNvdXBvbi84ODQ4NTktZGlzY291bnQtaW4tY2FydC1iYXNlZC1vbi1jdXN0b20tZmllbGRzP3RtcGw9bWFya2Rvd24=) 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.100 seconds

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

[](#top)
