Magento Core API: listing all shipping methods - magento

The cart_shipping.list method in the Magento Core API does not return all shipping/payment methods enabled on the admin site. The enabled methods are Flat Rate, Table Rates, Free Shipping, UPS, USPS, FedEx and DHL. Calling cart_shipping.list only returns Flat Rate, Free Shipping and UPS.
Any ideas as to why?
My main suspicion (when looking at the getShippingRatesCollection() function of the Mage_Sales_Model_Quote_Address class) is that the shipping address set for the order is used to filter some of the methods out. However, I don't fully understand how this filtering occurs, since in the front end this problem does not occur when using the same shipping address (i.e. I can see all the shipping methods that I expect to see for that address).

I have found a working solution to this issue, at least in my case.
The problem was that I was not specifying a Store Id in any of the methods used to create a cart and specify its products and delivery/billing addresses leading up to the call to cart_shipping.list.
These methods are: cart.create, cart_customer.set, cart_customer.addresses and cart_product.add. They all take a Store Id as an optional parameter. Specifying this store ID leads to all shipping methods visible in the front end for the same product and delivery address being displayed.

Related

Magento: where do I find the implementation of GETTER: Mage_Sales_Model_Order::getTotalPaid()?

My payment processor confirms that my clients paid the correct amount, while magento (in admin order info) "says" that the order still has a totalDue of 1 cent.
I really want to see how this GETTER: Mage_Sales_Model_Order::getTotalPaid() looks like, but I can not find the implementation.
I do not have a running installation atm, but i assume that totalPaid is just a standard attribute that's retrieved by magentos magic accessor in Varien_Object (__call).
There is no explicit set or get for that kind of variable.
The data is set in Mage_Sales_Model_Order_Invoice::pay(); and/or Mage_Sales_Model_Order_Payment::pay()
The error come from the creation of the invoice, a rounding issue due to tax configuration (tax on quote total instead of tax on each product row).

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 get chosen shipping and billing method address fields

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();

Magento: don't send tax to paypal/don't show tax in paypal emails

I'm using magento 1.7, and one of the payment options is Paypal (UK) express checkout.
The problem is that I don't want paypal to send out emails with any tax breakdown on, is there a more straightforward way of solving this (at the Magento or Paypal end) rather than hacking the core module to pass sub+tax as sub and 0 as tax?
I can see that a lot of the fields are mapped in Model/Api/Nvp.php, but can't immediately see where I'd modify these values.
As far as I investigated, there is no easy configurable way to prevent taxes to be submitted to Paypal.
But indeed there is a core hack if you don't mind that only the total amount is submitted (no line items, no taxes).
Go to System/Config/Paypal and set Transfer Cart Line Items to No.
In your code go to function _validate() in class Mage_Paypal_Model_Cart.
At the end of this function add the following lines:
$this->_areItemsValid = false;
$this->_areTotalsValid = false;
Of course it is nicer to to rewrite this class in your app/code/local folder.

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.

Resources