Magento get chosen shipping and billing method address fields - magento

How can I get the choosen shipping and billing fields during checkout? (I want to show them in sidebars)
I use this in shipping.phtml but ofcourse that's just for the current 'address' (and I want to use it in methods.phtml and other pages)
$this->getAddress()->getFirstname()
So I assumed that this would work out...
Mage::getSingleton('checkout/session')->getShippingAddress()->getFirstname()
But it didn't, anybody has a tip?
Addition:
This one was helping me a lot, but I'm stuck :-S
How do I get the shipping method the user has chosen during checkout?

Shipping and billing addresses are children of quote object. So something like this shall work:
Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress()->getFirstname();

Related

What could cause Magento to change new address back to default address on Paypal redirect?

I'm getting a strange bug in Onepage checkout using Paypal Express.
Logged-in Customer enters new billing address "on-the-fly", sets 'Save in Addressbook' and 'Ship to this address', then proceeds through checkout.
Address is saved in the database correctly at this point.
Customer chooses Paypal and Magento goes through it's logic (collection totals, saving quote - twice and data checks, etc).
I've stepped through the logic using Xdebug and am not able to pinpoint exactly where but right before redirecting to Paypal in /app/code/core/Mage/Sales/Model/Quote.php on line 318 in afterSave() callback, there's a line
if (null !== $this->_addresses) {
$this->getAddressesCollection()->save();
}
In $this->getAddressesCollection(), the billing and shipping addresses are wrong, they're both the Customer's default. However, the database is still correct.
Once the ->save() fires, the correct ones are overwritten.
It certainly appears to be Magento bug but I need to find a solution. This is EE 1.11.1.0.
Anyone experienced this before?
Thanks
I had a similar bug and maybe its the same with you. If you select an address as your default address in the address book it screws up the one page checkout.
Say I have 3 people in my address book: John, Suzy and Bill.
One day I happen to be in my address book and I select John as my default billing and shipping address. Then I go to my cart, order some items, select John as billing, and select ship to a different address. On the next step I select Suzy as my ship to address. I click next to go to the shipping method step, but whoa, wait! Suzy's address has been overwritten and replaced with Johns address.
Its exactly the same issue posted about here (although I dont think the guy understands what happened, but the screenshots are the same result): http://www.magentocommerce.com/boards/viewthread/7520/P0/
The issue is in the opcheckout.js file. I have a fix. basically once a default address is selected the add new address form (hidden form) is always populated with your default address.
Normally, without a default address selected in address book, I believe that the opcheckout.js properly fills in the hidden fields with the address you selected in the select box.
The following modified opcheckout.js script: ( http://pastebin.com/chiwyRJZ ) will fix it so that the hidden fields are properly filled with the correct data. From what I understand is this is an old unfixed bug, perhaps from whichever version Magento added the Add New Address form in one page checkout
To apply the fix, copy the code from paste bin and replace it with the code in your themes opcheckout.js
Usually opcheckout.js is in skin\frontend\default\yourtheme\js
OR
\skin\frontend\base\default\js
I know it is too late to post this, but I faced this issue on Magento 1.9.x. not only on paypal, but all other payment methods.
Check this method witch called upon creating new Quote:
public function assignCustomerWithAddressChange

Magento Free shipping ONLY on standard shipping

I am having no problems setting up free shipping for certain items with shopping cart rules. However, it being Christmas time, I want to offer free shipping on standard shipping, but leave Express shipping at it's regular price. When I setup the shopping cart rule to give free shipping to a specific item it automatically reduces every flat rate shipping method to $0. Is there a way around this?
Please check the screenshot it might help you.. here regular is the shipping code for Standard shipping and i have added extra condition if order amount is more than $100.
Best of luck, Let me know if you have any issue.
I had a similar problem and I found a solution.
The Problem: Multistore website with multiple shipping method: flatrate, matrixrate. In some store the free shipping rule should be applied only to matrixrate and not flatrate, in some others should be applied to flatrate.
The Solution: Use the rule like explaned here with whatever condition but the shipping method one. Then create a module that extend the Flatrate model (or the one witch shouldn't be affected by the rule) for prevent to apply the shipping rule according to a configuration specific for website.
More info here: https://magento.stackexchange.com/a/173063/4647

Magento. How to change shipping method before save order?

I must change shipping method before saving order if (condition) is true, and don't change it if false. I tried out function checkout_type_onepage_save_order($observer).
$checkout = Mage::getSingleton('checkout/type_onepage');
$checkout->saveShippingMethod('freeshipping_freeshipping');
but it doesn't work.
Sorry for my English.
Thanks.
I have had problems with things not saving properly in checkout, e.g. shipping address. I think you have to save the quote object again, but I cannot remember for sure.
However, why don't you write your own shipping module? This is the place for doing it properly and within your own module you can put together all the rules you need to set the price to what it needs to be, plus the frontend label, e.g. 'Free!' if a zero price is calculated.
Here is a tutorial that has worked very well for me in the past:
http://www.excellencemagentoblog.com/magento-create-custom-shipping-method

Virtuemart Coupon Plugin based on quantity not value

I've had a look at available Virtuemart plugins and I can't find anything close to what I am after. This is what I need.
Allow admin user to create coupon codes. An import feature would be nice as there will be thousands but I can handle this bit if needed anyway.
The admin user selects the number of products the customer is allowed for each coupon code.
When the customer uses the coupon code they are allowed to choose any product on the website up to the total amount of products issued to the coupon. Regardless of the products price.
Nice extra would be to allow free shipping with the coupon.
I've looked at the possibility of extending virtuemart and I think it would be possible. It would however require quite a lot of changes and if I can find something that is halfway there it would help me on my way.
Thanks in advance.
OK well time was running out and I didn't get an answer so I rolled my own. It was actually fairly painless. I can't release the code but I can give you a good idea of the steps and a direction to go in.
extend vm_ps_coupon and override the update, add and process methods. Add and update should only require a change to the array that is sent to the DB. See here for more info on extending classes
Alter the enum in the database to allow for quantity as well as total and percent.
Within your new update method handle the variation of quantity to do as you need.
In the update method you can also set a flag for free shipping in a session variable.
In templates/checkout edit list_shipping_methods.php. Simply check for the free shipping flag and load the free_shipping class. You can then call free_shipping->list_rates($vars);
extend vm_ps_checkout, override the add method, call the parent add method and then check the result so you can delete the session variable for the free shipping.
Finally you will need to make some changes in the HTML. Unfortunatly i could not find a way to override this easily and since its only two small changes to the markup i just went ahead and hacked the core. If anyone knows of another way that would be great? I did see something online about using a Joomla hook and a System plugin but I'd rather keep it reliant on Virtuemart only.
In administrator/components/com_virtuemart/html/ edit coupon.coupon_form.php to show the new quantity radio button.
Then edit coupon.coupon_list.php to display the correct values. Currently it will only display percent and total.
Hope this helps someone in the future. If you need some assistance then post on here and I'll be happy to help.

order approval for magento

I ’m in need of setting up approvers for orders that customers submit.
There is no credit card authorization required. For example, an employee from a company puts foo and bar into their shopping cart and checks out. One of the employee’s bosses need to approve it (the superiors will have accounts in magento already) before they can be invoiced. So when an order is placed, an email needs to go to the bosses, with a URL to the order. Then they can accept it or decline it.
Is there an existing extension that does something like this or would be a good starting point?
Yep, there is. :)
Check out the free ZetaPrints Order Approval extension. I have experience with it and it does exactly what you want. ;)

Resources