I've setup a german magento store and I'm struggling with displaying the total shipping cost.
This problem is really bugging me. I try to display the total shipping cost in the magento 'cart view' (Just one tiny step before the checkout).
I've setup table-based shipping and it's working fine in the checkout process at least...
I tried googling before asking this question but none of the answers helped me at all because most of them are over 3 years old.
My question in short:
Is it possible to get the shipping cost (based on the current items in cart) via PHP?
Is there a specific block or helper I can call to get the shipping cost?
I wan't to get the shipping cost at grandtotals.php in %my-theme%/template/tax/checkout/grandtotal.php
I've tried the following solutions:
<?php $k = Mage::getSingleton('checkout/cart')->getQuote()->getTotals();
echo $k['shipping']->getData('value'); ?>
or:
Mage::getSingleton('checkout/cart')->getQuote()->getGroupedAllShippingRates();
and several other solutions. Maybe these don't work for magento 1.8?
Could you guys give me a clue or possibly a super short tutorial how to set up these Magento Event Observer?
Related
Note - im new, so please be kind. If anything isnt clear please tell me, so i can improve my questioning!
As a person who lives in europe and sells products to end-consumers, the following problem is very ipmortant and in my opinion heavily under-prioritised.
There are a lot of conversation regarding this issue. In the following one #MikeJolley (owner of the wocommerce github repository) was also involved(github.com issues/4131) and linked to the site - How Taxes Work in WooCommerce where you can find the following filter to remain the prices constant regardless of the tax rate
add_filter( 'woocommerce_adjust_non_base_location_prices', '__return_false' )
By using the filter you can achieve the following:
Example 1: Selling from GB (with their 20% tax rate) to Germany. The price of the product is 9.99 including tax. GB based sellers do not need to charge tax for physical goods in Germany.
Price = 9.99 (the same)
Tax = 0 (no tax is charged
The German would pay 9.99 for the product, the same as GB people.
Example 2: Let's take the same above example, but consider a digital good where tax would apply of the rate 19%.
Price = 9.99 (the same)
Tax = 9.99 / 1.19 = 8.39 (slightly less than GB)
The German would again pay 9.99
The Problem:
For a few weeks i put the filter in my functions.php and solved the isse, unfortunately after the last Woocommerce update the mentioned filter triggers the following post call - wich executes in a infinite loop - again and again (see firebug network tab).
https://testsite.com/online-shop/?wc-ajax=get_refreshed_fragments
My request
Any idea how to solve this Problem - or any other way to remain the prices constant? Im not interested in heavy or paid Plugin solution wich slow down my site. Thank you so much
EDIT:
After some research i came across with the following:
Refresh fragments infinite loop #10940 and Fix for #10940 - wc_cart_hash
It seems there is woocommerce bug wich is still not resolved entirely. I closed my other windows and the problem is gone. What a waste of time...
After some research i found the problem. It is a woocommerce core problem - look at Refresh fragments infinite loop #10940 and Fix for #10940 - wc_cart_hash
wc_cart_hash was used as a key for localStorage
for all WooCommerce sites. If you were to load your
cart for two different sites in the same browser,
the two WooCommerce pages would contend over this key
and loop on trying to set this key in the localStorage
This commit prepends the site's ajax URL onto the wc_cart_hash
key name in localStorage, providing a unique key for each
WooCommerce site. This ends contention over the keys.
It seems the woocommerce bug is not resolved entirely...
I closed my other windows and the problem is gone. Hope this helps others with the same problem.
UPDATE:
The problem also happens if you open a new Tab where you view a live preview (under Appearance - Themes) of another woocommerce theme in the backend... In my case i checked a few changes of a earlier theme.
I have a little problem. A client of ours setup a WooCommerce shop himself and forgot to add taxes. Since he was in over his head he decided to get help setting it all up.
Now unfortunately this shop is already live and has about 50 completed orders in it. I setup the taxes etc. correctly for him but this will work only for new orders, not the old ones.
Does anybody know a simple way of adding the taxes to the old orders (all prices are including tax), maybe a loop or something I can run over the orders to get the taxes calculated?
I tried something really simple, just constructing the order and calling calculate_taxes() but this will only add a tax of 0,00€ to the order, so I guess I'm missing something important here:
$order = new WC_Order(1234);
$order->calculate_taxes();
Thank you for your help
What I did was:
1. update the product to pending payment.
2. recalculate the tax, change status to complete again, and set order action to send invoice to customer
that's it.
Alright, I dove really deep into the the mechanics behind this, so I think I can answer this myself, but be warned, it's more complicated then it seems.
There are some important things about how WooCommerce handles orders before though:
Shipping costs have to entered without taxes
Prices are stored without taxes in an order, even when you added them including taxes to the product
So when you add taxes after there are completed orders, that leaves you with the following problems:
The prices need to be changed in the old orders
The shippings costs need to be chached in the old orders
In more technical words, you would have to loop through all orders, loop through the items in the order, update prices, add the tax, update the shipping costs and only then can you run "calculate_taxes()" as I did in my really simple example.
I can't provide you with a finished function that does all this (yet) since I first have to clarify if the client is willing to pay for this. I'll add the function if he does. If anybody stumbles upon this and writes this function fell free to post is as an answer, I'll accept it as correct.
Is it possible to hide the shipping method step on the magento checkout process. I want to remove the shipping method step only on checkout page, not permanently.
What i am trying to achieve is on the cart page when the customer enters his postcode for shipping estimate and then update total. I will want to use his choice he made here for his order. So I see no relevance for him to alter his shipping choice afterwards as I only have one shipping option.
I have searched around and found there are ways of removing the step altogether and enabling a default shipping method. However I am using a table matrix so the shipping charge differs based on postcode entered, so i can not set it as a default.
Please can you advice if it is possible to achieve what I want and if so how would I approach it.
Advice and guidance is appreciated.
Thanks
I was wondering if anyone here has ever added an automatic discount to a shipping method in magento before. FedEx is the only company I ship with, but I have 3 different methods of FedEx. I want to add a discount to 2 of the 3 methods, and display these discounts at the method selection screen automatically at checkout(to make it seem like they are getting a deal with the higher priority shipping I suppose?). I found which file displays the methods, but I don't think this is the file I need:
template/checkout/onepage/shipping_method.phtml
Does anyone know which file these are displayed in so that I can slash out the real price, and add the discounted price bellow it? I suppose I could change the shipping price by just subtracting from the variable price, correct?
I suggest this thread for adding custom discount price but its not related to any of shipping method price calculation, its might helpful, as its helped me well..
http://www.excellencemagentoblog.com/magento-add-fee-discount-order-total
a bit of a funny one for you this afternoon.
This is in Magento 1.5.1.0...
Essentially, my website sells products that are free (£0.00) however the customer has to pay for delivery. The problem that I’m having, is that at checkout, the Payment Methods simply doesn’t load whenever the basket sub total is 0. Even when the Grand Total with Shipping is an amount.
I’m running One Step Checkout, however it doesn’t work on the default One Page Checkout either.
I’ve tried everything, and I’m certain that it’s not got anything to do with the Payment Gateways that I’m using.
I tried the same thing on another site of mine, that’s running 1.4 and it works fine on there?
You can see a screenshot of the page with the problem here...
Any help would be really appreciated.
Check that you have: "Zero Subtotal Checkout" enabled under: System -> Configuration -> Payment Methods.
Subtotal is pre shipping, tax and discounts, this payment option exists specifically for your circumstance.