Incorrect shipping calculation in Magento - php

I have a Magento site which uses the webshopapps matrixrates plugin for shipping rates.
The shipping cost doesn't seem to be calculating correctly and appears to apply a discount to the product cost.
In the screenshot below, the basket contains one product that has a price of €30, the shipping option 'European Airmail' (€5.50) has been selected.
Therefore the total cost should be €35.50
However the cost comes out at €30.55.
It's almost as if the Delivery cost is subtracted from the total (ignoring euro cents)
Interestingly there are two instances of this site, the UK instance appears to work correctly but I can't find anything different in the config.
I've tried comparing a CSV export of shipping rates but can't see anything obviously different.
What do I need to do to get the cost to come out as the correct amount (€35.50)?
Any suggestions welcome!
EDIT
If I dump out the quote object, the price for the product shows up as 25
But if I just load the product and dump it's data, I get the actual price which is €30:
I've got the tax amount with:
<?php
$taxAmount = $quote->getShippingAddress()->getData('tax_amount');
?>
And that comes back as 0.000
So I'm at a bit of a loss as to what is going on here.

Got to the bottom of this, it was a catalogue price rule for free shipping upto 4.95..
I had removed all shopping cart price rules already but wasnt aware that anyone had created a catalogue price rule so didnt consider it. Thanks for the suggestions guys.

Related

Woocommerce - display price in two currencies at the same time?

For legal reasons I'll soon have to display all prices in local currency + EUR at the same time.
I have WPML with multicurrency enabled, and I can set an exchange rate there. Problem is - it only works with currency switcher widget, and doesn't allow me to display both currencies at the same time (one under other). So, the other price is already calculated somewhere, but I don't know how to retrieve it and display it by adding something to functions.php of child theme.
Alternatively, there is no need to use WMPL Multicurrency here. Exchange rate is fixed, so it would be sufficient to just somehow divide the original price with fixed exchange rate and display it with other currency symbol. I'm aware that original price is already HTML formatted and contains the original currency symbol. Hence - no arithmetic operations can be used unless it's converted to number and currency symbol is stripped.
I've tried using this solution: Display prefixed price and additional unit price in Woocommerce simple products, but I end up with prices like this:
Original price: 99.00 $
Calculated price with fixed "exchange rate" entered in $unit_divider = 1.1;: 90.00 $ €
Note that here I managed to do the calculation and conversion, but I'm stuck with $ symbol.
P.S. I only need to display the price on product pages and archives - it's not necessary to have both currencies in cart and checkout (but it would be great to have that too!).
Thanks for help!

How can I add a checkbox on a product page in WooCommerce that adds a fixed fee when checked?

Here is the trouble I'm having. I'm creating a custom kitchen cabinet doors and drawers website with Woocommerce. There are a lot of variations going into the project that alters the price (Wood type, thickness etc.) per square foot. The customer also has to provide credentials (L x W) to calculate the total cost of the product. We found that using the Measurement Price Calculator plugin works the best as it also calculated the weight of the product which can be used for shipping.
However, we want to add an option (preferably checkbox) that adds a fixed fee to the product if checked. Using WooCommerce itself and having "Boring" as a variable attribute doesn't work because adding a charge here will only add to the price per square foot and will not be fixed regardless of the dimensions.
I'm not a master at PHP and have only found ways to add a surcharge in the checkout but I need the fee to be conditional to the checkbox being checked and be replicated based on quantity. If there are any functions or hooks that you think could help me please let me know.
What you are looking for is a part of WooCommerce that was separated and turned into a paid plugin called WooCommerce Product Add-Ons.
Koda

WooCommerce: Adding tax to old (completed) orders

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.

Adding discounts to shipping in magento

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

Magento quote_item and tax

I need to add custom attributes to selected products in store. To do so I'm using Model_Price_Observer. I'm using Magento 1.7.
So far I'm able to add custom attribute but calculated price is wrong - tax is missing.
My code is (part):
$quote_item->getProduct()->setIsSuperMode(true);
$quote_item->setOriginalCustomPrice( $customprice );
$quote_item->setCustomPrice( $customprice );
$quote_item->setTaxAmount($taxAmount);
$quote_item->setBaseTaxAmount($taxAmount);
Any ideas what am I doing wrong?
Am I using right trigger?
Tax cannot be added to an item as we do not yet know the customer's location in the world, and therefore cannot reasonably calculate a tax rate. I assume Magento is not saving your new tax information because of this fact. It also seems dangerous to me to add tax manually as it is always calculated on the fly via (sometimes) complex logic.
In the cart, try getting a "quick estimate" by entering in your country and postal code and see if tax is applied to the quote, and maybe try again.

Categories