Author Topic: Problem with multiple prices  (Read 3386 times)

sandomatyas

  • Jr. Member
  • **
  • Posts: 278
Problem with multiple prices
« on: February 25, 2015, 09:22:06 am »
I have a webshop with Joomla 3.3.6 and VirtueMart 3.0.6 and I want to add a special price to one of my products which is available for three days.
So I selected the product to edit, added a new price but I can't set the date ranges
  • If I add a new price and click on the start date, the datepicker shows up but if I click on a date nothing happens
  • The first price is fine but if I select a start date for the first price and I try to add a date for the second price, the second datepicker changes the first field: http://awesomescreenshot.com/0f04hdt210

I've just tested it on the official demo site and the problem appears there, too.

Could you fix it please? Or is there a fast hotfix maybe? I should use it very soon.
Thanks

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9854
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Problem with multiple prices
« Reply #1 on: February 25, 2015, 10:09:16 am »
Thank you, I check it now.
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9854
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Problem with multiple prices
« Reply #2 on: February 25, 2015, 10:49:03 am »
hunted down
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

sandomatyas

  • Jr. Member
  • **
  • Posts: 278
Re: Problem with multiple prices
« Reply #3 on: February 26, 2015, 07:34:38 am »
Is there maybe a hotfix?

sandomatyas

  • Jr. Member
  • **
  • Posts: 278
Re: Problem with multiple prices
« Reply #4 on: February 26, 2015, 14:36:03 pm »
Couple more things.

Could you help me use this tool? The main goal is create a one day discount. I mean the product have a standard price which is e.g. €10 but I want to set a special discount price just for a day e.g. €8. How can I manage this? What happens if there are two active prices for the product? The first one doesn't have publish_up or publish_down value, because it is the standard price. I add a new price with date limits or even just a publish_up or just a publish_down value but how can I know which one is the active one?
In my opinion the best way would be some kind of ordering of the prices. There is a drag&drop with the price boxes but I can't see an order field in #__virtuemart_product_prices. So if there would be an order field you could use the first matching price. If I check the loadProductPrices function in VirtueMartModelProduct class the value of the ORDER BY clause is 'ORDER BY product_price DESC'. The higher price is always 'stronger'?

Another question: The type of the date range fields in the database is DATETIME. It means VM stores the whole date with time but on the admin I see only a date field. Moreover, the format is with a two-digits year. Can I change it somehow to 4 digits year at least? However a datetime picker would be much better, then I could add a hourly discount, too.

And the third one: What's about the timezones? The created_on and modified_on fields are in UTC but what's about the publish_up or publish_down fields? My shop is in UTC+1 CET timezone. If I set the price ranges to a date it gets a 00:00:00 time in the database. When will be my price active in UTC?

Sorry about the lot of questions :)

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9854
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Problem with multiple prices
« Reply #5 on: February 26, 2015, 14:52:19 pm »
The ordering would lead into big confusion.
The ordering is by value and if there is a conflict (more than one price available) it takes the higher price
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

sandomatyas

  • Jr. Member
  • **
  • Posts: 278
Re: Problem with multiple prices
« Reply #6 on: February 26, 2015, 15:13:25 pm »
Okay I can accept this. But maybe a flag for the direction? Higher/lower price if there is a confict?

sandomatyas

  • Jr. Member
  • **
  • Posts: 278
Re: Problem with multiple prices
« Reply #7 on: March 03, 2015, 10:24:11 am »
I've just checked the latest 3.0.6.2 version.
I can use the datepicker on the fields but I can't use the date reset icon.
I've checked a source a bit and as far as I can see you might need a change in the vmJsApi helper in the line 714.
The original is:
Code: [Select]
$(".js-date-reset").click(function() {But it might need this, because the second price is dynamically created:
Code: [Select]
$(document).on( "click",".js-date-reset", function() {If I change this line it works well.

sandomatyas

  • Jr. Member
  • **
  • Posts: 278
Re: Problem with multiple prices
« Reply #8 on: March 04, 2015, 10:16:40 am »
Another price-related problem:
Somethimes I can't delete a product price if I have multiple ones. I click on the red icon, the JavaScript removes the box but if I save it comes back.
I checked the sourcecode and found this:
In the VirtueMartModelProduct there is a script to delete prices if there are some unnecessary ones.
Let's assume that I start a new shop and I have one price to one product. It means in the database I have the same virtuemart_product_price_id  and virtuemart_product_id because both tables have autoincrement ID fields.
But now I add a product with two prices. So my virtuemart_product_id==1 and there are two prices with virtuemart_product_price_id==1 and virtuemart_product_price_id==2
Then check the code around line 1771 in the product model:
Code: [Select]
if(array_search($pricesToStore['virtuemart_product_price_id'], $oldprice )){If we had two prices and we wanted to delete one of them (e.g the first one), at this point we have one ID in $pricesToStore['virtuemart_product_price_id'] (==2) and the $oldprice array with two elements (both of price record from the database).
The code wants to check if we have a price to keep. But if we use array_search, its always true in this scenario because the function returns true because it finds the $pricesToStore['virtuemart_product_price_id'] (==1) as a 'virtuemart_product_price' field in the $oldprices array which is also equals 1.
So I think it would be better if we wrote a simple check instead the array_search, like this
Code: [Select]
if($pricesToStore['virtuemart_product_price_id']==$oldprice['virtuemart_product_price_id'] ){It would find the exact match with the correct field of the array.
I've checked it on my site and I think it works well.

lindapowers

  • Full Member
  • ***
  • Posts: 1335
  • If you're going through hell, keep going.
    • Venta de naranjas online y mandarinas
  • Skype Name: manu.gonzalez91
  • VirtueMart Version: Latest avi
Re: Problem with multiple prices
« Reply #9 on: March 04, 2015, 10:44:46 am »
I confirm this bug too. The only way to remove multiple prices is removing all prices, saving and adding them again. Bug present in vm2 & 3.

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9854
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Problem with multiple prices
« Reply #10 on: March 05, 2015, 17:25:32 pm »

I cannot reproduce ...

The code wants to check if we have a price to keep. But if we use array_search, its always true in this scenario ....

I doubt it, furthermore the code handling the price is 100 lines. The line you are talking about is checking if an old price entry is to be reused.
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9854
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Problem with multiple prices
« Reply #11 on: March 06, 2015, 17:11:33 pm »
I am sorry, I cannot reproduce it. I also tried with j3.4. I created 5 prices, in 2 steps. I deleted them, one time the last, or one of the middle, or the first, works always for me.
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9854
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Problem with multiple prices
« Reply #12 on: March 06, 2015, 17:23:15 pm »
I've just checked the latest 3.0.6.2 version.
I can use the datepicker on the fields but I can't use the date reset icon.
I've checked a source a bit and as far as I can see you might need a change in the vmJsApi helper in the line 714.
The original is:
Code: [Select]
$(".js-date-reset").click(function() {But it might need this, because the second price is dynamically created:
Code: [Select]
$(document).on( "click",".js-date-reset", function() {If I change this line it works well.

Thanks, yes that should work. But as you maybe noticed, this parts of the code are quite old. I think the .on method was not even available at that time. One of the changes from 3.0.4 to 3.0.6 was to change at least some of the frontend js to use the new .on method. We are going now more and more to change it. If you have more updates like that, always welcome.
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

sandomatyas

  • Jr. Member
  • **
  • Posts: 278
Re: Problem with multiple prices
« Reply #13 on: March 07, 2015, 06:53:40 am »
Sure, I'm always looking for a solution too.
BTW I sent you a message yesterday about the multi-price problem

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9854
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Problem with multiple prices
« Reply #14 on: March 07, 2015, 09:39:02 am »
As I said, it works perfect for me. Do you work maybe with a migrated product?
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/