I am building an on-line store to sale sweets. I added sweets box as bundle products. Before buying sweet, customer has to select box first. each box will have limit on quantity. for example box 1 contains 4 sweets, box 2 contains 12 etc. After selecting box, on options page, suppose I selected box 1. I selected 4 sweets. now I want to buy few more sweets. so there is a need to have an Ajax call to increment box quantity.Please help me with this. Thanks in advance.
It is my advice that you find a different way. I think you are suggesting using ajax to change the product (to a different bundle) and then move the 4 sweets from the initial bundle to the new bundle. That is a very complicated thing to do. An full answer here would need many lines of code.
I suggest you allow the user to pick the sweets first, then ask them to pick a box - the box must be big enough so you might give your box products an attribute sweets_maximum and set that to 4 or 12 and use some logic to only display boxes that are big enough.
Then maybe the cost of the sweets is zero and the boxes non-zero (so you can apply the price for the box and not the sweets).
Alternatively, load the sweet_maximum and the bundle SKUs and all the sweets skus into one webpage and after the user selects the number of sweets, write code to pass back to Magento the correct SKUs to add to the cart ie 10 different sweets SKUs and the SKU for box 2.
Bundles are very complex. I don't think you want to be ajaxing them back and forth.
*EDIT following comment below
Then this (from my answer above) is my recomendation: do everything in the browser and then pass back to Magento only the box and sweets chosen - your Javascript would form the URL to the bundle controller with the appropriate product selections.
*Alternatively, load the sweet_maximum and the bundle SKUs and all the sweets skus into one webpage and after the user selects the number of sweets, write code to pass back to Magento the correct SKUs to add to the cart ie 10 different sweets SKUs and the SKU for box 2.*
If you really want to use ajax you are going to be jumping through a lot of hoops. Here is the psuedo code I would use. You can find the functions by using the defualt Magento theme and capturing the submission URLs from the bundle pages and the cart-updates and reading the code in the controller actions.
(server side)display the chosen bundle
(browser side)UI logic to decide when a different box is needed
NO, WAIT. Maybe we need more information; it is difficult to do a full code architecture in this forum.
//new psuedo code
Carry on as normal. Allow the user to pick any box and any number of sweets through out the entire shopping experience
Eventually the user will visit its cart.
As part of the cart display logic, count the total sweets and count the total box capacity. If box capacity < total sweets, prompt the user to choose a bigger box.
Why do I say this? I mean there is a lot of shopping scenarios to work out but if you are really doing these as bundles then the bundle is not in the cart until the user presses the add to cart button - that is why I say the browser should have the logic to change the box in the browser without ajaxing anything. Can a user buy sweets separately?
I don't know what to say. I am happy to help you but we are opening a can of worms as far as the logic is concerned and without a specific list of all shopping scenarios and all allowed buying logic I find it difficult to assist. But I think if you write down all the logic you will find the answer yourself. Don't be afraid to advise your client on different ways to do this.
The URL for adding a bundle to the cart is:
POST http://54.247.95.57/checkout/cart/add/product/13831/ HTTP/1.1
product=13831&related_product=&bundle_option%5B767%5D=3867&bundle_option_qty%5B767%5D=1&
The URL for removing a bundle is :
POST http://54.247.95.57/checkout/cart/updatePost/ HTTP/1.1
update_cart_action=update_qty&cart%5B48677%5D%5Bqty%5D=0
But I still say do it all in the browser.
Related
Goal
I am upgrading a custom in-house module for magento EE. The module groups clients together and has special rules that can be applied to the group or individuals of the group. I need to add an extra tab that allows, on a per group basis, to select items and/or categories. When they are selected people within this group will not be allowed to see those categories or products.
What I have
I have the the tab created and I know what I need to do on the front-end to achieve my goals. The issue is creating the selector. I have played with it for a couple hours and made no real headway as of yet. I have only been doing magento development for the past 5 weeks, so I am very new to this framework.
What I need help with
I would like to select the categories and items in the same fashion as when you go to Catalog->Categories->Manage Categories. The left column has a tiered list. I would like to have one like this but with check boxes for selection. When looking at Promotions->shopping cart rules->actions(tab), select a rule, choose the actions tab. In the second fieldset, if you add a new rule 'category' and then select the icon for the tiered tree that is exactly what I want. Same idea for products, its okay if the look is different. Just need to be able to do it both ways.
I need to be able to store the selected values, and retrieve them (easy once I know how to store them).
Please provide any code, guidance, or links to tutorials which are in the ball park. It would be much appreciated. I'm sure the generic option of being able to select things in this manner would be helpful to all.
I have this idea to make a product page that lists all the products on the site, Perhaps paginatied, and have them all have a quantity box on the right side of them.
This way, people who stock my product can go to this page, enter the quantities for all the products they need and click "Add to cart" at the top or bottom of the page.
Saving the stockist time by adding 40 of each product they want etc.
Has this been done before? Can it be done?
Of course this is possible. In terms of magento quite everything is possible. If your question "Has this been done before?" aims to an extension-suggestion. Sorry, but i don't know one.
But in simplest case a "small" custom module could do the job. Simply add a custom attribute to the categories (e.g. wholesale = yes|no), override the catalog/category/view.phtml by your module-layout-update and check this attrib within that "new" view. If it is "yes" list all products out of this category in the way described above.
Processes of "add to cart" with the right qty out of a categoryview exist already but you need to trigger them e.g. by a custom javasscript just before the page swaps. and you slightly have to mod the "add to cart" itself to prevent jumping into the cart afterwards. Its just an example, would work for non-configurable/non-optioned products at least.
If it has to be an own page listing all products of the shop, your module has to provide a bit more up front (controller, viewblock, etc.) but that more could be also helpful with implementing own logic, eg. collecting all qty in a session first and ask later for "add to cart"
I'm evaluating Magento for a particular client of mine. They want to enforce a particular workflow for browsing the catalogue. They're a travel company which puts together custom holiday packages and want to make sure users enter things like the number of adults / children before selecting accommodation (as number of people will affect available accommodation and pricing).
Note that accommodation is just an example, there are several other different components to a holiday package. And they've given me a 7 step (mostly) linear workflow they want users to follow before we get to anything which might resemble a checkout process (and even then their concept of "checkout" is quite different to Magento's).
I'm thinking of storing accommodation (and each of the other package components) in separate product categories. Then I can restrict what users can see as they browse the catalogue based on what they've already added to their shopping cart.
My research indicates that Magento doesn't really do this kind of thing out of the box. Am I mistaken? Are there add-ons which would support this kind of thing?
If I was to go down this road, would I be redesigning (or indeed, replacing) a large chunk of Magento's catalogue browsing functionality?
Well there are several approaches that you can take to implement something like this; but all require that you do custom development work.
You could define your packages as simple products with attributes for each of the specific package options and use that to filter each package from the others, now you would need to create a new module that adds a route on the frontend that is going to be your multistep form that will get all the information once you have all the information you can get a collection of all the products(packages) that match those attributes.
Now the deal there is if that price changes depending on the options selected if that's the case then you might need configurable products or something custom to change the price of each package.
It's really hard to say without real specifications of what your client needs, but if the question is if it's possible with Magento then the answer is yes it all depends on your level of skill :)
Kind Regards
So I ended up going with Magento as a product base and extending it using some custom code (been a while since I've developed in a LAMP environment!)
I created a static block which is used as the root of the workflow. There are 8 steps in the workflow which get listed in an ordered list. Each item has two custom Magento widgets next to it, which are a) a little tick image displayed when you've completed the workflow stage and b) a link which displays when you're up to that stage, clicking the link takes you to an appropriate catalog page (eg: choose accommodation, hire car, confirm shopping cart, etc).
I disabled the normal top catalog navigation to encourage users to keep within the workflow. That is, the mouse over to see more catalog detail of the "holiday planner" is disabled (although you can just navigate to the correct urls if you know them, or are smart enough to use the SEO link at the bottom of the page!).
Everything in your holiday is added as cart products (which has the positive side effect of Magento will remember your holiday if you get part way through it).
There is a big state machine in a helper class to determine what stage of the workflow you're up to. This checks your cart to see if products with particular sku's or from a particular attribute set are added.
I also overrode many URLs and redirects (eg: after you add a product) to send the user back to the root holiday planner page. This added to the workflow as almost every action you did or product you add bounces you back to that workflow page (which always tells you what the next step is).
Ok so what I want is to have multiple simple products draw from the same stock.
Scenario
I have a sinle nail file (Stock:500)
I have a box of nail files (50/box)
I want it so that if someone buys a box then it deducts from the 500 stock of the singles. Essentially what we do is if someone buys a box, then we ship them 50 of the single files in a box.
Any easy way to do this?
This isn't a native function of Magento, so there a few approaches you can take to emulate it:
Use an external stock management package to keep track of stock and modify Magento to use that. This will require more backend modification.
Attempt to fool Magento by using product bundles in clever ways. This will require more frontend modification
Develop or find a Bill of Materials plugin for Magento. I didn't see anything after a short search, so you may have to build it. Have that module check the constituent materials for a product before allowing it to be added to the cart.
Hope that helps!
Thanks,
Joe
Consider:
Create a template for the products that you wish to order this way. This template need only be the files you need to modify, by default it will find the missing files from your default theme;
In the template you can place some PHP to write out some extra javascript, of the prototype variety;
This frontend code hides the real quantity box, with prototype 'hide' for the relevant css id to make it a hidden form field;
The code shows its own quantity box, also an extra field for how many of the fifty packs are required;
An onchange event on these boxes gets the values of the boxes, does the required multiplication and addition, then updates the hidden 'real' quantity box with (boxes*50)+singles;
On submit the customer sees in the cart the total quantity of the product ordered - this will be total units, not broken down 'per box'. If this is a problem, you can put some words to explain that or modify your main template to handle this and present to the customer the boxes+singles breakdown;
Set your products to use the 'new theme' that has your template update code.
Test, test, test!
As mentioned by Joseph this cannot be done out of the box. The above workaround is only partial, however, so long as you make it clear to customers that they are buying 500 units instead of 500 boxes then you should have a reasonable solution.
Is it possible to have a bundle product that when added to the cart adds each of the bundle items as individual line items.
I want to allow my customers to configure their product (let’s say it’s a computer) and then in the shopping cart, remove an item they don't want - or change their mind about - from that bundle. They might then choose to add a new item instead - or a bunch of other (non-bundle stuff, just normal shopping).
The idea being that they have a fast method of adding most of the stuff they want in this bundle, but they can then edit their cart to add something that wasn’t available as an option to them when configuring the bundle.
I don’t want to overload the user with too many options in the bundle product page.
I might have missed an option in Magento, but currently it adds all the bundle items into the caret as a single line item, making it uneditable in the way I want.
Any suggestions please?
This behavior in Magento is intentional, as you may not want to let a customer order a PC without a CPU or memory. In your case, this assumption appears not to be the case, but that remains the method for using bundled products.
There are a few options open to you to avoid this situation. Firstly, you could use some product type other than bundle, and actually add simple products to your cart rather than the bundled ones. This would allow customers to add options at will, but would not preserve any promotional pricing on the products, as Magento checks those prices/discounts on every page load, and would kick out any changes you set manually.
The other option would be to allow customers an easier path to changing the bundle product that they have chosen. When rendering the bundle product, you could render a little X button (or whatever you find appropriate), which would lead to an action you specify, whose job it is to change the bundle options, resave the cart item, and redirect the user back to the cart. This is probably the cleanest solution to the problem.
Hope that helps!
Thanks,
Joe