VirtueMart Forum

VirtueMart 2 + 3 + 4 => Product pricing => Topic started by: PromoNet on October 05, 2013, 12:11:30 PM

Title: Can't delete prices
Post by: PromoNet on October 05, 2013, 12:11:30 PM
Ok so I clicked "Add new price" added a price in.  Then Saved it.

I realised that I didn't need the prices so I went in and pressed the red X to remove them.  Saved but they are still there.

I think this is a bug
Title: Re: Can't delete prices
Post by: AH on October 05, 2013, 15:56:36 PM
are you using vm 2.0.24
Title: Re: Can't delete prices
Post by: netr on December 17, 2013, 14:37:58 PM
I have the exact same problem. I am using VM 2.0.24c, Joomla 2.5.16.
The whole site was migrated from old Joomla 1.0 and VM 1.0 to the newer version (if this may have any impact on the problem).
Title: Re: Can't delete prices
Post by: jenkinhill on December 17, 2013, 14:52:48 PM
Working OK for me in VM2.0.26
Title: Re: Can't delete prices
Post by: netr on December 17, 2013, 15:50:00 PM
I updated to VM 2.0.26 and price deletion still does not work.
I have php 5.4.21 on the server.

Can you give me some pointers on where to start debugging?

-edit-
I noticed, that I can delete all prices for some product and after that, I can add a new price.
However, I still can not remove only one price (if I have multiple prices).
Title: Re: Can't delete prices
Post by: EVC on January 17, 2014, 15:38:12 PM
Ditto can't remove prices once set. The red X never worked for me. VM V2.024
Title: Re: Can't delete prices
Post by: Agaton on February 12, 2014, 11:12:13 AM
Issue still exists on vm 2.0.26d and joomla 2.5.18 on apache/linux server
Title: Re: Can't delete prices
Post by: amymattian on February 12, 2014, 18:57:36 PM
Having the same problem on 2.0.26d and linux server.

Also when I have added special price for 4 pieces it does not show up in frontend! Anyone know what can be causing this?

Greetings,
Anne
Title: Re: Can't delete prices
Post by: worknmn on March 12, 2014, 11:28:00 AM
I have same problem - can't delete added prices.
I am find feature in code of the product model.... There are build array for delete entry from database.

            $toUnset = array();
            foreach($old_price_ids as $key => $oldprice){
              if(array_search($pricesToStore['virtuemart_product_price_id'], $oldprice )){
                $pricesToStore = array_merge($oldprice,$pricesToStore);
                $toUnset[] = $key;
              }
            }

PHP function array_search scan all array $oldprice with same as value of $pricesToStore['virtuemart_product_price_id']
But it's wrong. Because we need check one field - virtuemart_product_price_id
I change that so:

            $toUnset = array();
            foreach($old_price_ids as $key => $oldprice){
              if($pricesToStore['virtuemart_product_price_id'] == $oldprice['virtuemart_product_price_id'] ){
                $pricesToStore = array_merge($oldprice,$pricesToStore);
                $toUnset[] = $key;
              }
            }


File for edit \administrator\components\com_virtuemart\models\product.php
Search string "if($pricesToStore){"
Title: Re: Can't delete prices
Post by: Milbo on March 12, 2014, 12:48:20 PM
I just tested it. It works fine for me.
I added a price, stored it,... deleted the added price, removed.
I added a price, stored it,... deleted the FIRST price, is removed.

Do you have the problem maybe if you have more than 2 prices?
I added two prices at once, stored, both are there. I deleted the price in the middel, is removed,.. hmm. I cant see the problem.

Quote from: amymattian on February 12, 2014, 18:57:36 PM
Having the same problem on 2.0.26d and linux server.

Also when I have added special price for 4 pieces it does not show up in frontend! Anyone know what can be causing this?

Greetings,
Anne

This is correct. The multiprice feature works so that only one price is chosen and then used as the price. You can show the prices in vm2 with a bit layout hacking. But in vm3 it is native onboard and only a template/layout issue.
Title: Re: Can't delete prices
Post by: worknmn on March 12, 2014, 15:37:18 PM
Quote from: Milbo on March 12, 2014, 12:48:20 PM
I just tested it. It works fine for me.
I added a price, stored it,... deleted the added price, removed.
I added a price, stored it,... deleted the FIRST price, is removed.

In my way $pricesToStore['virtuemart_product_price_id'] value is equal with $oldprice['virtuemart_product_id'].
That's thy function array_search return true for record which should be delete.

Why you think is right to check value for all values of the array, if we need check only one $oldprice['virtuemart_product_price_id']?