add and remove product options in shopping cart - php

Humm..After trying so many shopping cart codes by customizing according to my requirements I still not got proper solution.:(
I have two tables products and productoptions in which i stored the color or size of product. One product can have different sizes and colors.
Now the problem is I am unable and frustrated to integrate/ customize the code according to above scenario. There are issues coming like I can't add one product with two different colors and remove one of them. While removing one of them, the cart becomes empty.
Can anyone please suggest me how should I achieve the shopping cart with above scenario? Any online reference examples or any relevant source demo will be helpful if someone had done this type before.
Friends please suggest. I doing this first time. Thanks in advance.

It's simpler than you think.
Use sessions.
So let's say these two products have an id of 1.
Let's also admit there's no stock check, and you have an unlimited amount of products.
Whenever you add a product to your cart, add to $_SESSION['products'][]['item'] id of 1. You can also add ['color'] and such. But this will be one item.
At this point, you'll have to loop over your $_SESSION array to display your products.
Do it, and mark the div containing your product with the index that corresponds to its slot in your $_SESSION created earlier, with an input hidden for example.
Now whenever you'll click on delete, you should send the index marked in the div to the code deleting the product from cart.
With the index, delete the corresponding array in $_SESSION['products'].
Once this is done, only the remaining products will be displayed and counted in the cart.
This is only one method among many. Using AJAX is advised for a better user experience, it'll be more fluid.
But if you're new to all this, starting with simple PHP is advised.

Related

Magento Attribute Sort Order in Configurable Product

I need help with the following:
In Magento I have created a configurable product and assigned some simple products to it. They have an individual attribute set with individual, numeric attributes that I have created.
One attribute is for example "length". This attribute has the following values:
3,4,5,6,7,8,9,10,12,14,16,18,20
If I open the drop-down menu on the article details page, the values get displayed like that:
10,12,14,16,18,20,3,4,5,6,7,8,9
Thus, it seems that the attributes are saved as text (alphanumerical?) and not as numbers (numerical)?!
I need some advice on how I can change that. I have tried to work with "Input Validation for Store Owner" in "Manage Attributes", but that doesn't work. Is there f.e. any field in my database where I can simply switch the way my attributes are saved/displayed?
I have created many products and attributes, thus I don't want to re-create all of them again, if not necessary.
Thanks for any reply.
It has been a long time since you asked and might be you have already found a solution to it. I am just writing so that anyone coming on this page for the same problem does not have to go thru the same pain what i went thru.
When you create the attribute(length), you would have created the options (like 3/4/5.. etc) create the sort of that options in the attribute section and they will sort as per your requirement.

Shoe/Shirt Size clickable list instead of drop down menu

I'm stuck here. I'm trying to create code that will list out all of the available sizes for the item without using a drop down. In the two links below you will see what I am talking about. Any items that are out of stock are grayed out and when you click on an item in stock the item availability comes up in red below your selection.
Can anyone point me in the right direction (maybe a tutorial) in how to get this done? I'm trying to implement it in my magento site. Would I need to use php or is there an option in magento?
Shoe Examples:
http://www.karmaloop.com/product/The-AR-20-Sneaker-in-Craft-Blue-Running-White/263936
Shirt Examples:
http://www.karmaloop.com/product/The-We-Win-Hoody-in-Black/271919
To do what you want, first you would have to create configureable products (for all the size/option per product) to keep track of which option is out of stock.
The easiest way I can think of is to create a custom module and modify /app/code/core/Mage/Catalog/Block/Product/View/Options/Type/Select.php to make Unordered HTML list then use css to style. (you could use javascript to do this but you may run into this issue How do you stop Chrome and Opera sorting JSON objects by Index ASC?)
Then take a look at getJsonConfig() in app/code/core/Mage/Catalog/Block/Product/View/Type/Configurable.php this will produce a json object that is available on the product page and should which product is in stock. Then you can use javascript/css to highlight which is in stock.
This is a example of one site that i work on http://www.contempospace.com/bedroom-furniture/wardrobe-closets/custom-closet-systems/isa-custom-closet-4-module/isa-closet-system-xl-maximize-large-closet-drawers-shelves-hanging.html with that functionality. But as the previous person mention this is a big request. I would reccommend to find a pay/free module and then make any changes you need.
Configurable Products in Magento
This will help !!

Search by SKU but show Grouped Products that have that SKU associated

I need my quick search to search by SKU. I know that's the way Magento works by default but unfortunately that's only for simple products (I think).
In my case, I have a store that uses simple products set to "not visible individually", and then I have grouped products that associate those simple products. Only the simple products have the SKU attribute but they're only shown when you open the grouped product.
What I need then, is to have it search inside those grouped products for the simple products with the SKU entered in the quick search field, and then display the grouped products that have a match.
Is there anything that does this? Seems to me it should be baseline in Magento.
Edit: Magento 1.4.2
Working on this issue right now. The solution I'm thinking of trying is suggested here:
http://www.magentocommerce.com/boards/viewthread/74229/
The idea is to set the simple product visible in search instead of not individually visible. Then in the product template check if the simple product is part of a group. If so JavaScript redirect to the grouped product page.
Still thinking about a cleaner solution but thought this might be of some help.
Not sure if people are still looking for answers to this, but i was so I'll post my resolution anyway :)
Simply add all the SKU's with a space onto the SKU of the grouped product. Then when someone searches for one of them, it will bring up your grouped product. Then you need to do nothing to the simple products at all, they can remain hidden. Also works for configurable items.
Hope I help someone!
IP

Ubercart add to cart form with quantity option per attribute

I need the add to cart form on each product to display separate quantity fields so items of different attributes can be added at the same time. This is for a photography site, so it makes sense for the customer to order 2 6x4 prints and one 10x8.
Right now the add to cart form is something like this:
Here is a mockup of what I want to have:
I have no idea which hooks to use, or if it's even possible to add multiple product variants in one POST. Is anyone familiar enough with the Ubercart api to tell me how I can go about doing this.
I found this googling for a solution to the same problem. Unfortunately I couldn't find anything.
So I made a patch and sent it in to an issue with a similar request - http://drupal.org/node/782154#comment-3925090
The patch isn't tested very well yet, but I will be going live with it or a subsequent solution in a couple of weeks.
Hope it helps.

PHP: Buy both and save $50?

OK my client wants to show a buy both feature in the cart, if they have 1 particular item type in the cart they want it to show up for another particular item type so if they buy both they can save $50 off the total. I am trying to wrap my head around what would be the best way to set this up so it couldn't be easily hacked (ie: adding both to the cart then removing one and keeping the discount)
does anyone have some general ideas in theory?
Thanks.
Why not perform the check right before they submit the order? that way, everytime they get to the submit order page, it will check if both items are present.
easy enough - always calculate the final price on the fly based on the current cart contents. The issue you mention seems like it would only be a problem if you were calculating the final price and caching it somehow.
usualy it'd done by creating a new bundle item. It's a bit dirty but works :)
Are they using a system already, or is this a custom job on your part?
Add the discount to the cart and use another table to keep track of the discount's dependencies. Whenever an item is removed from the cart, check to make sure the discount is still valid. If it is, great. If not, remove it and recalculate the cart price.

Categories