WooCommerce change tax per product programmatically - php

The problem is: If we sell a ticket to our customer, we pay the tax not where the customer lives and not where the company of the shop is located. We pay the tax, where the event is held.
We can use a workaround where we can define a tax class for each country, with the rate. But this is very ugly.
I would like to develope something where I can set the country for the events and WooCommerce will use this country as a tax base, just for this product.
My problem is, that I don't know which filter I should apply. I found some, but the filter don't give the product object or the product id as parameter.
For example: https://docs.woocommerce.com/wc-apidocs/source-class-WC_Checkout.html#468
Does someone have an idea?

thanks for getting back to me. That's the "hack" I implemented but it solved for me
I used the filter woocommerce_price_ex_tax_amount (there is also, woocommerce_price_inc_tax_amount) for inclusive tax calculation.
It receives $tax_amount (already calculated), $key, $rate, $price.
You can setup a fictitious tax rate for every ticket and modify it programatically. As you'll receive the price as well, you can recalculate the rate base on it and return it.
Hope it helps,

Related

WooCommerce Fixed Coupon Price

I am using WooCommerce, and how create two fixed price for one product ?
standard price product
coupon using fixed price
If user enter coupon code, will show coupon fixed price, else standard price.
When you use coupons in woocommerce you can set if you want to deduct a percentual or a fixed amount. You can also limit to certain products only.
So you could basically assign a coupon to the one product with a fixed discount value.
i've found this plugin while browsing around.. maybe it could help to get the job done
(I'm not affiliated to that company/developer)
http://sarkware.com/woocommerce-change-product-price-dynamically-while-adding-to-cart-without-using-plugins/#override-price-wc-fields-factory

Getting product weight info in virtuemart inside order details/order history page

I have the following problem in virtuemart:
I have made a function to calculate shipping cost based on a five stage cost given by the shipping company. This works perfectly on the cart page, but on the order details and order history page it does not, as I cannot get the product weight in these pages.
I have looked into order_items.php where the order details references are kept, but there is no reference to the product weight, only to product id, quantity, category, etc.
Could anyone help me in how to get the product weight inside the order details page? I can do the rest in calculating the shipping rates and updating the final sales price, but I am stuck in getting this info.
Any help is welcomed :)
Try this,
I think you missed something about order tables, hope you are using VM2.x
In this version once the order is processed its payment,shipment information gets saved on the #__orders table.
In additionally the payment method Id and Shipment method Id also gets saved. So you can identify the method used on the order.
The idea of calculating ordered products shipping cost later on admin side is not practical bcoz later the shipping cost may very.
So practically once the user placed an order that time you have to save these information on the above table. If you're using VM default Shipping plugins they will do this by default.
Hope its clear.

Magento tiered pricing change format

At the moment, my webstore uses several different customer groups to provide discounts, such as trade discounts. The functionality works fine, but i want to change the way the prices are displayed on the front end. Right now, the prices show like this:
£700.00
Buy 1 for £450.00 each and save 36%
For instance. So the customer is logged in, they can see the Retail price and then their price is the £450. I wish for it to say
List Price: £700.00
Your Price: £450.00 (save 36%).
Is this possible?
The other issue is that when a customer is not logged in, i just want them to see the list price, and not the discounts etc.
How would i do this?
Yes its possible. You have to play with the file price.phtml and/or view.phtml.
To get original price, use getPrice() method on your product object. To get discounted (final) price, use getFInalPrice()
Product object is usually $_product, so
$_product->getPrice();
$_product->getFinalPrice();
Now you may display however you wish.

Programmatically add product to Virtuemart?

For a customer I am building a Virtuemart 2.0.26d website.
Because of a local law, for each unit of a product that is ordered a fee must be added.
So, when ordering 4 products, the fee must be charged 4 times. By law it is required that the total sum of this fee is visible on the invoice/order confirmation.
I looked at the price rules in Virtuemart, but they don't seem to have an option for this. There is a price modifier after tax, but then the fee is visibile as an negative discount. Something I don't want.
The only solution I came up with is to make a new product for the fee and programmatically add this product for each unit. Can this be done by making a Virtuemart Plugin, or must I change the core for this?
Or are there better solutions for this problem?
You can add extra charge by Taxes & Calculation Rules.
create new rules and select tax per product for Type of Arithmetic Operation and select Math Operation + Or +% as per you want to add extra fee per product.
You could add a custom field to each product with the fee amount and alter the code of the payment plugin to add this fee to your order.

Prestashop voucher system

The problem I am having is related to voucher codes.
By default, Prestashop will apply a discount of a particular product to the total of the entire cart. For example, if I have 3 products in my cart, all priced at £100, the total sum of the cart is £300.
If i have a voucher for a total value of £200 that is valid for only 1 of the 3 products in my cart, the behavior I want to achieve is that Prestashop will recognise that the voucher is valid for only one product, and rather than deducting the £200 voucher total from the cart total (essentially applying the remainder of voucher credit to the other two, non applicable items), it will deduct only the amount of all applicable items (in this case, £100), and some how create a new voucher for the remainder of the credit.
Hopefully this makes sense and many thanks in advance for any help offered.
Cheers
The only way to do it now is to create a new category (hidden), place the product in there (in addition to the current place), and assign the voucher to the new category.
Source
In PrestaShop, you can create a voucher for an individual category, but not yet for a specific product. At this point, product-specific vouchers would require changes to the code in several different places. As mentioned in Narek's source link, this is something the PrestaShop team is working on for a future release, but that functionality is not currently available in the default installation of PrestaShop.
Source: I am PrestaShop's Community Manager

Categories