How to clear data using a button? LARAVEL - laravel

Scenario: My website does shoe orders. When a user proceeds into buying a shoe, it goes to pending orders. My problem is that when the user presses the back button of the browser, the order data is loaded and still be available to be purchased and proceed to pending orders.
Is there a way that I can make the back button of the browser to erase the order details after proceeding to pending orders?

check this answer - that should do the trick, BUT it's quite common that if you add goods to the cart, it stays there and it doesn't matter if you pressed the back button or not.
So, is it really necessary to catch this scenario? Is it causing any problem? If so, I would personally use a cron job to remove unpain pending orders (in the last X hours)

Related

magento increment bundle product quantity on options page

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.

special price - how to remove in mass?

I hase set some special price, with a start date, and no end date.
Now I want to remove all the special price.
so no discount.
I went to the catalog view, I select ALL products, and clicked on "change attributes".
I've check the "updated" checkbox beside start date, and special price.
then I click apply.
I can see the special price disappeared, but... on the front end, I can still see the promotion!
How is it possible?
Now note that If I select a product on the backoffice, and If I click on "save" (without editing anything) then it works on the front end!!
Of course I re-indexed everything and cleared the cache.
I have 20k products so I cannot select all products one by one to click on "save"
thaks for your help
Rod
I use magmi for this. Most bulk operations are possible here. You'll definitely need this if you say you have 20k+ products.
Outside of this solution, you'll probably have to do stuff manually, write a script to manage the mass update, or write a direct SQL statement to update this. I'd post a query here but it can be too varied because of Magento's EAV system.

Missing UPS Shipping Methods on the Magento Frontend

What would cause ups shipping methods that are selected in magento's shipping method admin page to not show up as shipping options to customers. Specifically I'm trying to get the ground commercial option to show up on the frontend.
I've done some research on this, it seems like this questions been asked a before and never answered (that i can find) so I'll ask it again and throw in my research on the subject.
I've traced the source code from the shipping cost estimations in the shopping cart and found that when you enter a zip code it creates an entry in the 'sales_flat_quote_address' table with basically just the postcode and id fields filled.
It also creates rows in 'sales_flat_quote_shipping_rate'. one for each applicable shipping method for that quote/address pair.
When magento lists the shipping options it references this table.
Somewhere between the shipping methods admin and this database table some of the shipping methods are filtered out.
I think it has something to do with residential/commercial addresses. However ups's rating api cant determine if an address is residential/commercial if only given a zip code. Also changing the destination type in the admin page does not have an effect on which methods are displayed on the frontend.
For reference if all ups shipping methods are selected in the back end, the following are the only ones that show up on the front end:
ground
3 Day Select
2nd Day Air
Next Day Air Saver
Next Day Air
Next Day Air Early AM
This is out of 22 options selected in the backend.
Go to System > Configuration from admin panel
In the Configuration panel on the left, under Sales, click Shipping Methods.
Click to expand the UPS section. Then set enable to yes.

Magento custom browse catalogue workflow

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).

Event Observer - Trigger an event

I would like to create an event observer that I want to show a message / alert box when total weight of cart surpass 23 kg (to tell the truth, I want an event to check weight limit and trigger the alert box when customer add a product to cart).
Could anybody help me to make such an observer?
You don't need anything so involved...
Already you have been given the code to write the weight out, put this code in a block, put it in the header (or even your cart sidebar) and add an IF statement.
Don't just put
if($weight>23) { echo "Too Heavy - Shopping Cart is going to burst itselves!" }
put a custom variable in admin and compare it against that. In that weigh, if you change courier then your customer can update the max weight.
This link could help you :
http://www.magentocommerce.com/wiki/5_-_modules_and_development/0_-_module_development_in_magento/customizing_magento_using_event-observer_method
If you have SSH access, grep 'dispatchEvent' to get the list of all events

Resources