News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Problem with multiple prices

Started by sandomatyas, February 25, 2015, 09:22:06 AM

Previous topic - Next topic

sandomatyas

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

Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Milbo

Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

sandomatyas


sandomatyas

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

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
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

sandomatyas

Okay I can accept this. But maybe a flag for the direction? Higher/lower price if there is a confict?

sandomatyas

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:
$(".js-date-reset").click(function() {
But it might need this, because the second price is dynamically created:
$(document).on( "click",".js-date-reset", function() {
If I change this line it works well.

sandomatyas

#8
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:
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
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

#9
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


I cannot reproduce ...

Quote from: sandomatyas on March 04, 2015, 10:16:40 AM
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.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Milbo

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.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Milbo

Quote from: sandomatyas 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:
$(".js-date-reset").click(function() {
But it might need this, because the second price is dynamically created:
$(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.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

sandomatyas

Sure, I'm always looking for a solution too.
BTW I sent you a message yesterday about the multi-price problem

Milbo

As I said, it works perfect for me. Do you work maybe with a migrated product?
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/