Event Observer - Trigger an event - events

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

Related

How to clear data using a button? 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)

Shopify Script for Fixed Discount of a set price based on tags

Using Shopify Scripts :::
I am trying to achieve the below but getting issue. Could you please let me know how to do this.
$25 off a purchase of $125 or more from the "sale" section. These products have a tag "sale" and are also in a collection "sale" based on that tag.
Looking forward for your quick response.
Great Thanks
If you examine the documentation for Shopify Scripts you'll notice that there is no support for auditing the line item for tags. So you should try the other approach which is proven, and works well.
Look for an item with a compare at price. If you find one, then that typically means the item is on sale. So you can rig your logic to look for items with a compare at price, and if they have one, then determine if the cart has exceeded the $125 in value, and if so, apply your discount.
I can't give you the exact code as I don't know the structure of your code. But this is what you need to do.
Wherever a product can be added to the cart assign a JavaScript function to check if the product is of "Sale" collection. If yes, add an attribute cart.attributes.something.something and keep changing it as and when required.
When the checkout mechanism is present in the page, and if your conditions satisfy the Sale discount, take then to /checkout?DISCOUNT=<CODE> and click of checkout. It'll automatically apply the discount.

Magento - product that are not for sale

Does anyone know how to list products in Magento that are not for sale? I still want the items to appear in the store, but I would like the "Add to cart" function to be disabled. This seems like it would be something that is easy to set up, but I haven't been able to figure it out. Thanks in advance!
Set stock level to zero and disable backorders.
Our store uses this on occasion- Adding to what dick mentioned :
Set Stock to 0.
If your store allows out of stock items to be visible, then this will work immediately.
If you do not allow items to be visible once they are out of stock, you'll need to switch this setting in the backend.
Alternatively, you could set up a new product attribute that replaces the add to cart button with something different (more info button, popup, etc).
If you want to display for sale only then set it's stock qty to 0 and try to set option from admin like this go to your admin side click on system->configuration->catalog->inventory and set yes Display Out of Stock Products so that the product is display on front side without add to cart functionality
Hope this will help you

How do I add checkboxes to Magento's "Estimate Shipping and Tax" in the cart?

So, on the cart page, my customers can view the "Estimate Shipping and Tax" area. I don't want to remove it, but I need to know a little additional information from them to properly process the shipping. For example, on a freight item, I need to know if they have a loading dock.
Currently, I do this in the checkout without any issue. I was able to check if there is a freight item, and, if so, show the checkboxes to the customer during the "Shipping Address" stage. Then, in the saveShipping function, I was able to pull in the values and pass them to the shipping charge calculation.
Well, I've got the checkboxes in the template to display in the "Estimate Shipping and Tax" when there is a freight item in the cart, but I don't know much about the coShippingMethodForm function so that I can add in the values of the checkboxes. Anyone have any idea where I should be looked for this?
Additionally, when I hit "Get estimate", the page refreshes and it removes their selections. How best can I retain their selections to repopulate the correct boxes once the page refreshes?
I think that the best way would be to write your own shipping method module. I personally would steer clear of having a checkbox added to 'Estimate shipping and taxes' instead in my module I'd output both prices with loading bay, without loading bay (just for the estimates) in checkout you can get that option from the "Shipping Address" section and pass it into you shipping module calculation this is just a little 'cleaner.'
Check out this wiki for how to write a custom shipping module http://www.magentocommerce.com/wiki/5_-_modules_and_development/shipping/create-shipping-method-module

Increase product amount in shopping cart

We are selling ready made packs ( total weight 18 kg ) which is include several food products. But we want to make a special thing to our customers which they should make their packs by selecting our product range.
So that, they should make first a base pack with selected products then they can multiply this package in the checkout section.
What I want to do, modify the checkout section of magento to multiply selected products with a text field and calculate total amount by button.
Like in image...
Does anybody help me to make such a thing?
Personally I would do this with frontend code, in prototype. The reason being that you will have to modify your template anyway and your customers will need javascript enabled to get to your cart anyway.
General approach is to have the onclick for your apply button take the id.value for your quantity text box and then update everything with the quantity class in the cart page. Then have this script call the same update url as the standard update quantities button.
Here is my suggestion: in your module you create an observer listening to controller_action_predispatch_checkout_cart_index. In your observer's method you can get the items in cart with $itemCollection = Mage::getSingleton('checkout/session')->getQuote()->getAllItems();. now you just have to loop through this condition and set the quantity:
foreach ($itemCollection as $item) {
$item->setQty(here_the_integer_you_want);
}
edit: sorry, didn't read about the input and button.
For the input and button, you just have to edit the template (app/design/frontend/base/default/template/checkout/cart.phtml). Or, if you want tom make an independant extension, you could add them by an observer. Check out inchoo's post. This form you've just created will call your controller/action, where you can set the items quantity (so no need for an observer anymore), with the same technique I've put earlier.
Let me know if that's not clear.
HTH

Resources