Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.

helpme

 

Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.

 

Only one product per category at Virtuemart cart

Only one product per category at Virtuemart cart

Hi, Stephen.

I am using Joomla 2.5.4 and Virtuemart 2.0.6.

I would like to know if it is possible to use MetaMod Pro to delete one product from the cart if the user add to the cart a different product from the same category. I found here that it is possible to clear the whole cart, but I need to know if I can delete just the product that belongs to the same category and keep any other product from a different category.

I did purchase MetaMod Pro for Joomla 1.5 a while ago. Is it any upgrade price to buy the J2.5 version?

Thanks again for your very well done job and your great service.

vrans99
Beginner Modder
ranks
useravatar
Offline
4 Posts
Administrator has disabled public posting

Re: Only one product per category at Virtuemart cart

Hi,

1 - can you please remind me how you clear the cart? It should be possible to make that more targetted so that it just removes things from a particular category.

I should add however that this doesn't sound very user-friendly. Shouldn't you be looking for a way to hide items from a particular category once someone has purchased from that category? Instead, it looks like you're going to allow them to see the products, allow them to click "add to cart", but then mysteriously the products will get deleted from the cart again? (NB I don't know how else you would do it, but I think you should at least try to find another way)

2 - upgrades: there were free upgrades given to people who purchased the J1.5 version in the 3 months before the J2.5 version came out. Unfortunately due to the amount of effort it took to develop the new version there's no upgrade pricing.

Best regards,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3314 Posts
User info in posts
Administrator has disabled public posting

Re: Only one product per category at Virtuemart cart

Hi, Stephen.

metamodguy wrote:

1 - can you please remind me how you clear the cart? It should be possible to make that more targetted so that it just removes things from a particular category.

In a different topic (http://www.metamodpro.com/forums/topic?id=727) you have an answer about how to clear the whole basket, that's the one I was following.

metamodguy wrote:

I should add however that this doesn't sound very user-friendly. Shouldn't you be looking for a way to hide items from a particular category once someone has purchased from that category? Instead, it looks like you're going to allow them to see the products, allow them to click "add to cart", but then mysteriously the products will get deleted from the cart again? (NB I don't know how else you would do it, but I think you should at least try to find another way)

I will be selling web hosting plans. A customer has chosen the domain name and then the silver package for the hosting plan. But he decides to go back and choose the gold plan instead, he will have two different hosting plans for the same domain name. I know the customer can delete the silver plan from the cart, but sometimes they might forget to or don't realize it and keep both plans in cart. That will create a future problem (and I know that it is a problem with a solution) but I want to make it as simple as possible for the customers. It is not to hide a product, it is to delete the previous product from the cart and keep the last one from that particular category on the cart. I don't see anything dishonest or misterious on that.

For the upgrade price, it is fine and I understand that. It should be that way but I was just asking. I would be buying the full version.

vrans99
Beginner Modder
ranks
useravatar
Offline
4 Posts
Administrator has disabled public posting

Re: Only one product per category at Virtuemart cart

Ok, actually that makes more sense than I thought. I thought that you were not going to allow the *new* item to be added, but you mean that the new item will get rid of any old ones in the same category.

Actually I think this may be more difficult than anticipated. Part of the problem is knowing which of the products in the cart is the new one and which is the old one.

The other part of the problem is that Chameleon runs *before* the new product is actually added to the cart. The POST or AJAX request will have been received by Joomla, then Chameleon gets run, but at this point if Chameleon looks at the cart it will only have products in it that were added at an earlier time, NOT yet the new product that the user is adding. Also, the VirtueMart system itself has not been initialised at the time Chameleon is running, so you don't get access to the $ps_cart object like you do later.

I suppose it might be able to be done this way:
1 - detect if the POST/AJAX request is for adding a new product to the cart. If so, make a note of its category id
2 - check if there's something in the cart of that category
3 - if so, delete that product from the cart.

The original poster was using MetaMod which runs at a much later stage in the page cycle, when VirtueMart has been initialised. In that case it's easier to work with the cart object since it has been initialised, but by then the new product has been added to the cart and it may be difficult to determine which one to delete. Oh, and by that time most of the page has been generated, so the main component may still show the old item in the cart. So I guess doing this in the MetaMod isn't a great way to go.

Ok, I just looked at the cart data structure a little more closely, with a couple of products in the cart.

Bad news.

Part of the cart data includes the pricing situation for the entire cart. e.g. tax, sales prices, subtotals and the bill total.

If you remove something from the cart, all of this stuff is going to have to be recalculated. It's not just a matter of removing an item from an array, as I had first hoped.

It wouldn't be so bad if the VM system had been initialised by this point, as there may be API you could call to remove a particular item. But as this is not the case, you'd have to code something directly into Chameleon to handle all the pricing and subtotalling, and that's not going to be fun.

I would recommend finding a PHP developer who knows VM to work on this. It's beyond the level of Chameleon help, I am afraid.

Sorry about that,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3314 Posts
User info in posts
Administrator has disabled public posting

Re: Only one product per category at Virtuemart cart

Hi, Stephen.

Thank you for your ideas. You're sharp.
Can I use Chameleon to change stuff on my site? I thought that it was only to change the template. It would be interesting to know.

Can you be that PHP developer? I've been using your extensions and I have confidence on your skills.

If not, for my original question, maybe what I can do is to clear the whole cart if the customer decides to go back (like the other poster was trying to do). So the only inconvenience for the customer is that he will have to reselect the plan. At least is only one product.

Thanks.

vrans99
Beginner Modder
ranks
useravatar
Offline
4 Posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1685
Total Polls:
6
Total Posts:
5912
Total Posts Today:
4
User Info:
 
Total Users:
11504
Newest User:
toko solo
Members Online:
0
Guests Online:
112

Online: 
There are no members online

Forum Legend:

 Topic
 New
 Locked
 Sticky
 Active
 New/Active
 New/Locked
 New Sticky
 Locked/Active
 Active/Sticky
 Sticky/Locked
 Sticky/Active/Locked