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

#   Hikashop User Points - calculation problem

##

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

Less More

- Posts: 13
- Thank you received: 1
-
-

10 years 10 months ago -  10 years 10 months ago [\#222133](#222133) by [stephanie.pomerleau](/forum/user/39006-stephanie-pomerleau "View stephanie.pomerleau's Profile")  *[Hikashop User Points - calculation problem](/forum/30-integrations/880729-hikashop-user-points-calculation-problem#222133 "-- HikaShop version -- : 2.6.0 Business -- Joomla version -- : 3.4.1  I am having an issue with how points are being earned on purchase. I want points to be earned as 1 point for 1$ on specific categories only.  When the plugin is configured to earn 1 point for each dollar, with no product category specified (see: Capture-user-point-plugin-config-01.jpg), everything works as expected. 3 admissible products in the cart for a total of $49.50 earns 50 points (see: Capture-points-no-category-in-config.jpg)  When I add a product category in the &quot;Product categories&quot; field in the configuration (see: Capture-user-point-plugin-config-02.jpg) , the points earned are more than the rate that has been set. 49.50$ earns 83 points, but should only earn 50. (see: Capture-points-with-category-in-config-02.jpg)  With same configuration settings as previous (with product categories), when I have 2 different products, but in the same category, points are ok. $33 earns 33 points (see: Capture-points-with-category-in-config-02A.jpg)  If I have 2 identical products, points are multiplied, and actually earn more than 1 point per 1$. $33 earns 66 points (see: Capture-points-with-category-in-config-02B.jpg)  The problem is amplified when I put 9 identical items in the cart. 148.50$ earns 1337 points. (see: Capture-points-with-category-in-config-9-identical-products.jpg).  If I test using 1 product in the desired category, and 1 product outside the desired category (deos not earn points), the behaviour is as expected: points on the coffee, but not on the tea. $33 dollars, but only 16.50$ is admissible to points, and 17 points are earned. (see: Capture-points-with-category-in-config-1-product-not-in-category.jpg)  It looks like the points are calculated by multiplying the number of products by the subtotal of the product line (9 x 148.50$ = 1336.50 points, which rounds to 1337). I don't think this is the expected behaviour, and this should be fixed.  Thanks, Stephanie")* was created by *[stephanie.pomerleau](/forum/user/39006-stephanie-pomerleau "View stephanie.pomerleau's Profile")*

-- HikaShop version -- : 2.6.0 Business
-- Joomla version -- : 3.4.1

I am having an issue with how points are being earned on purchase.
I want points to be earned as 1 point for 1$ on specific categories only.

When the plugin is configured to earn 1 point for each dollar, with no product category specified (see: Capture-user-point-plugin-config-01.jpg), everything works as expected. 3 admissible products in the cart for a total of $49.50 earns 50 points (see: Capture-points-no-category-in-config.jpg)
[ ![Capture-user-point-plugin-config-01.jpg](/forum/attachment/28007) ](/forum/attachment/28007 "...-config-01.jpg")

[ ![Capture-points-no-category-in-config.jpg](/forum/attachment/28008) ](/forum/attachment/28008 "...-in-config.jpg")

When I add a product category in the "Product categories" field in the configuration (see: Capture-user-point-plugin-config-02.jpg) , the points earned are more than the rate that has been set. 49.50$ earns 83 points, but should only earn 50. (see: Capture-points-with-category-in-config-02.jpg)
[ ![Capture-user-point-plugin-config-02.jpg](/forum/attachment/28009) ](/forum/attachment/28009 "...-config-02.jpg")

[ ![Capture-points-with-category-in-config-02.jpg](/forum/attachment/28010) ](/forum/attachment/28010 "...-config-02.jpg")

With same configuration settings as previous (with product categories), when I have 2 different products, but in the same category, points are ok. $33 earns 33 points (see: Capture-points-with-category-in-config-02A.jpg)
[ ![Capture-points-with-category-in-config-02A.jpg](/forum/attachment/28011) ](/forum/attachment/28011 "...config-02A.jpg")

If I have 2 identical products, points are multiplied, and actually earn more than 1 point per 1$. $33 earns 66 points (see: Capture-points-with-category-in-config-02B.jpg)
[ ![Capture-points-with-category-in-config-02B.jpg](/forum/attachment/28012) ](/forum/attachment/28012 "...config-02B.jpg")

The problem is amplified when I put 9 identical items in the cart. 148.50$ earns 1337 points. (see: Capture-points-with-category-in-config-9-identical-products.jpg).
[ ![Capture-points-with-category-in-config-9-identical-products.jpg](/forum/attachment/28013) ](/forum/attachment/28013 "...l-products.jpg")

If I test using 1 product in the desired category, and 1 product outside the desired category (deos not earn points), the behaviour is as expected: points on the coffee, but not on the tea. $33 dollars, but only 16.50$ is admissible to points, and 17 points are earned. (see: Capture-points-with-category-in-config-1-product-not-in-category.jpg)
[ ![Capture-points-with-category-in-config-1-product-not-in-category.jpg](/forum/attachment/28014) ](/forum/attachment/28014 "...n-category.jpg")

It looks like the points are calculated by multiplying the number of products by the subtotal of the product line (9 x 148.50$ = 1336.50 points, which rounds to 1337).
**I don't think this is the expected behaviour, and this should be fixed**.

Thanks,
Stephanie

- [ ![Capture-user-point-plugin-config-01.jpg](/forum/attachment/28007) ](/forum/attachment/28007 "...-config-01.jpg") [ ](/forum/attachment/28007?download=1 "...-config-01.jpg")
- [ ![Capture-points-no-category-in-config.jpg](/forum/attachment/28008) ](/forum/attachment/28008 "...-in-config.jpg") [ ](/forum/attachment/28008?download=1 "...-in-config.jpg")
- [ ![Capture-user-point-plugin-config-02.jpg](/forum/attachment/28009) ](/forum/attachment/28009 "...-config-02.jpg") [ ](/forum/attachment/28009?download=1 "...-config-02.jpg")
- [ ![Capture-points-with-category-in-config-02.jpg](/forum/attachment/28010) ](/forum/attachment/28010 "...-config-02.jpg") [ ](/forum/attachment/28010?download=1 "...-config-02.jpg")
- [ ![Capture-points-with-category-in-config-02A.jpg](/forum/attachment/28011) ](/forum/attachment/28011 "...config-02A.jpg") [ ](/forum/attachment/28011?download=1 "...config-02A.jpg")
- [ ![Capture-points-with-category-in-config-02B.jpg](/forum/attachment/28012) ](/forum/attachment/28012 "...config-02B.jpg") [ ](/forum/attachment/28012?download=1 "...config-02B.jpg")
- [ ![Capture-points-with-category-in-config-9-identical-products.jpg](/forum/attachment/28013) ](/forum/attachment/28013 "...l-products.jpg") [ ](/forum/attachment/28013?download=1 "...l-products.jpg")
- [ ![Capture-points-with-category-in-config-1-product-not-in-category.jpg](/forum/attachment/28014) ](/forum/attachment/28014 "...n-category.jpg") [ ](/forum/attachment/28014?download=1 "...n-category.jpg")

Last edit: 10 years 10 months ago by [Jerome](/forum/user/80-jerome "View Jerome's Profile"). Reason: insert capture in message in order to be able to analyze it

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMwLWludGVncmF0aW9ucy84ODA3MjktaGlrYXNob3AtdXNlci1wb2ludHMtY2FsY3VsYXRpb24tcHJvYmxlbT90bXBsPW1hcmtkb3du) 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: 26394
- Thank you received: 4078
-
- [](http://obsi.dev)
-

10 years 10 months ago [\#222143](#222143) by [Jerome](/forum/user/80-jerome "View Jerome's Profile")  Replied by *[Jerome](/forum/user/80-jerome "View Jerome's Profile")* on topic *[Hikashop User Points - calculation problem](/forum/30-integrations/880729-hikashop-user-points-calculation-problem#222143 "-- HikaShop version -- : 2.6.0 Business -- Joomla version -- : 3.4.1  I am having an issue with how points are being earned on purchase. I want points to be earned as 1 point for 1$ on specific categories only.  When the plugin is configured to earn 1 point for each dollar, with no product category specified (see: Capture-user-point-plugin-config-01.jpg), everything works as expected. 3 admissible products in the cart for a total of $49.50 earns 50 points (see: Capture-points-no-category-in-config.jpg)  When I add a product category in the &quot;Product categories&quot; field in the configuration (see: Capture-user-point-plugin-config-02.jpg) , the points earned are more than the rate that has been set. 49.50$ earns 83 points, but should only earn 50. (see: Capture-points-with-category-in-config-02.jpg)  With same configuration settings as previous (with product categories), when I have 2 different products, but in the same category, points are ok. $33 earns 33 points (see: Capture-points-with-category-in-config-02A.jpg)  If I have 2 identical products, points are multiplied, and actually earn more than 1 point per 1$. $33 earns 66 points (see: Capture-points-with-category-in-config-02B.jpg)  The problem is amplified when I put 9 identical items in the cart. 148.50$ earns 1337 points. (see: Capture-points-with-category-in-config-9-identical-products.jpg).  If I test using 1 product in the desired category, and 1 product outside the desired category (deos not earn points), the behaviour is as expected: points on the coffee, but not on the tea. $33 dollars, but only 16.50$ is admissible to points, and 17 points are earned. (see: Capture-points-with-category-in-config-1-product-not-in-category.jpg)  It looks like the points are calculated by multiplying the number of products by the subtotal of the product line (9 x 148.50$ = 1336.50 points, which rounds to 1337). I don't think this is the expected behaviour, and this should be fixed.  Thanks, Stephanie")*

Hi,

Thanks for that detailed report.

In the plugin, when you have a filter on the product categories, the plugin will check each product and process the sum for all of them which are in the targeted categories : Code:

$product_price = 0.0; if(empty($product-&gt;prices) &amp;&amp; !empty($product-&gt;order_product_price)) { $product_price = (float)hikashop_toFloat(@$product-&gt;order_product_price) + (float)hikashop_toFloat(@$product-&gt;order_product_tax); } else if(!empty($product-&gt;prices)) { if(isset($product-&gt;prices[0]-&gt;price_value_with_tax)) $product_price = $product-&gt;prices[0]-&gt;price_value_with_tax; else $product_price = $product-&gt;prices[0]-&gt;price_value; } if(isset($product-&gt;order_product_quantity)) $product_price *= (int)$product-&gt;order_product_quantity; else $product_price *= (int)$product-&gt;cart_product_quantity;

In that algorithm, we want to get the unit price of the product ; but it looks like in your case it retrieve the global price.
So we will add few lines in order to force the reading of the unit price. Code:

$product_price = 0.0; if(empty($product-&gt;prices) &amp;&amp; !empty($product-&gt;order_product_price)) { $product_price = (float)hikashop_toFloat(@$product-&gt;order_product_price) + (float)hikashop_toFloat(@$product-&gt;order_product_tax); } else if(!empty($product-&gt;prices)) { $p = $product-&gt;prices[0]; if(isset($p-&gt;unit_price)) $p = $p-&gt;unit_price; if(isset($p-&gt;price_value_with_tax)) $product_price = $p-&gt;price_value_with_tax; else $product_price = $p-&gt;price_value; } if(isset($product-&gt;order_product_quantity)) $product_price *= (int)$product-&gt;order_product_quantity; else $product_price *= (int)$product-&gt;cart_product_quantity;

Let me know if it fixes your issue.

Kind regards,

---

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

The following user(s) said Thank You: [stephanie.pomerleau](/forum/user/39006-stephanie-pomerleau "View stephanie.pomerleau's Profile")

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

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

Less More

- Posts: 13
- Thank you received: 1
-
-

10 years 10 months ago -  10 years 10 months ago [\#222262](#222262) by [stephanie.pomerleau](/forum/user/39006-stephanie-pomerleau "View stephanie.pomerleau's Profile")  Replied by *[stephanie.pomerleau](/forum/user/39006-stephanie-pomerleau "View stephanie.pomerleau's Profile")* on topic *[Hikashop User Points - calculation problem](/forum/30-integrations/880729-hikashop-user-points-calculation-problem#222262 "-- HikaShop version -- : 2.6.0 Business -- Joomla version -- : 3.4.1  I am having an issue with how points are being earned on purchase. I want points to be earned as 1 point for 1$ on specific categories only.  When the plugin is configured to earn 1 point for each dollar, with no product category specified (see: Capture-user-point-plugin-config-01.jpg), everything works as expected. 3 admissible products in the cart for a total of $49.50 earns 50 points (see: Capture-points-no-category-in-config.jpg)  When I add a product category in the &quot;Product categories&quot; field in the configuration (see: Capture-user-point-plugin-config-02.jpg) , the points earned are more than the rate that has been set. 49.50$ earns 83 points, but should only earn 50. (see: Capture-points-with-category-in-config-02.jpg)  With same configuration settings as previous (with product categories), when I have 2 different products, but in the same category, points are ok. $33 earns 33 points (see: Capture-points-with-category-in-config-02A.jpg)  If I have 2 identical products, points are multiplied, and actually earn more than 1 point per 1$. $33 earns 66 points (see: Capture-points-with-category-in-config-02B.jpg)  The problem is amplified when I put 9 identical items in the cart. 148.50$ earns 1337 points. (see: Capture-points-with-category-in-config-9-identical-products.jpg).  If I test using 1 product in the desired category, and 1 product outside the desired category (deos not earn points), the behaviour is as expected: points on the coffee, but not on the tea. $33 dollars, but only 16.50$ is admissible to points, and 17 points are earned. (see: Capture-points-with-category-in-config-1-product-not-in-category.jpg)  It looks like the points are calculated by multiplying the number of products by the subtotal of the product line (9 x 148.50$ = 1336.50 points, which rounds to 1337). I don't think this is the expected behaviour, and this should be fixed.  Thanks, Stephanie")*

And where do I find the file that has this code that I need to change? Sorry, I am new at HikaShop ![:)](/media/kunena/emoticons/8.png ":)")

UPDATE: found the file: plugins/hikashop/userpoints/userpoints.php

Last edit: 10 years 10 months ago by [stephanie.pomerleau](/forum/user/39006-stephanie-pomerleau "View stephanie.pomerleau's Profile"). Reason: update info

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

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

Less More

- Posts: 13
- Thank you received: 1
-
-

10 years 10 months ago [\#222264](#222264) by [stephanie.pomerleau](/forum/user/39006-stephanie-pomerleau "View stephanie.pomerleau's Profile")  Replied by *[stephanie.pomerleau](/forum/user/39006-stephanie-pomerleau "View stephanie.pomerleau's Profile")* on topic *[Hikashop User Points - calculation problem](/forum/30-integrations/880729-hikashop-user-points-calculation-problem#222264 "-- HikaShop version -- : 2.6.0 Business -- Joomla version -- : 3.4.1  I am having an issue with how points are being earned on purchase. I want points to be earned as 1 point for 1$ on specific categories only.  When the plugin is configured to earn 1 point for each dollar, with no product category specified (see: Capture-user-point-plugin-config-01.jpg), everything works as expected. 3 admissible products in the cart for a total of $49.50 earns 50 points (see: Capture-points-no-category-in-config.jpg)  When I add a product category in the &quot;Product categories&quot; field in the configuration (see: Capture-user-point-plugin-config-02.jpg) , the points earned are more than the rate that has been set. 49.50$ earns 83 points, but should only earn 50. (see: Capture-points-with-category-in-config-02.jpg)  With same configuration settings as previous (with product categories), when I have 2 different products, but in the same category, points are ok. $33 earns 33 points (see: Capture-points-with-category-in-config-02A.jpg)  If I have 2 identical products, points are multiplied, and actually earn more than 1 point per 1$. $33 earns 66 points (see: Capture-points-with-category-in-config-02B.jpg)  The problem is amplified when I put 9 identical items in the cart. 148.50$ earns 1337 points. (see: Capture-points-with-category-in-config-9-identical-products.jpg).  If I test using 1 product in the desired category, and 1 product outside the desired category (deos not earn points), the behaviour is as expected: points on the coffee, but not on the tea. $33 dollars, but only 16.50$ is admissible to points, and 17 points are earned. (see: Capture-points-with-category-in-config-1-product-not-in-category.jpg)  It looks like the points are calculated by multiplying the number of products by the subtotal of the product line (9 x 148.50$ = 1336.50 points, which rounds to 1337). I don't think this is the expected behaviour, and this should be fixed.  Thanks, Stephanie")*

Your code fixed the problem, thank you!!

The following user(s) said Thank You: [Jerome](/forum/user/80-jerome "View Jerome's Profile")

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

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

[](#top)
