Programmatically add product to Virtuemart? - php

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.

Related

Wordpress add product fees to subtotal

I am having a problem with the following:
I use "TM extra product options" to add some extra options when buying a product. For example:
Box of chocolate (€40,00)
Extra decorations (extra option) (€15,00)
I offer free shipping on orders above €50,00. The problem is, that the extra fees are calculated AFTER the subtotal, and the shipping is calculated based on this subtotal. In the example above, you still have to pay for the shipping, which i don't want to.
How can I make sure the fee is calculated inside the subtotal (but still mentioned as seperated product) of have the shipping calculated based on the subtotal+fees?
Thanks in advance!
PS:
Something along this way:
$woocommerce_subtotal = $woocommerce_subtotal + $woocommerce_product_fee;
// set fee on 0 after this line
$woocommerce_product_fee = 0;

WooCommerce change tax per product programmatically

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,

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

Make magento 3rd item from cart free

I need to know if there is a way to create this in Magento:
First of all, all my products price are fixed: 9.99$.
So i want to do this: if the client bought three products, the third is free, so it pays 2 products. He can do this as many times as they want, so if you buy 6 products, there will be 2 product free, if he buys 9 products, 3 are free
Magneto supports buy x get y free promotions. Information about setting them up is available at http://www.magentocommerce.com/knowledge-base/entry/how-to-setup-buy-x-get-y-free
It's possible to do this using magento Shoping Cart Price rules.
Create a Shoping cart price rule by going to your admin panel and clicking on Promotions -> Shoping Cart Price rules.
Create a condition for your rule. There is a nice GUI to define the conditions so they will look like: If an item is FOUND in the cart with ALL of these conditions true
Define an Action, actions describe how prices are updated when the conditions of the rule are met. In your case there is an specific action called: Buy X get Y Free, which defines a quantity that the customer must purchase to receive a quantity for free. (The Discount Amount is Y.)
Complete the labels: lables appears on the order below the subtotal to identify the discount. You can enter a default label for all store views, or enter a different label for each view.
Apply the rule. Make sure you save and enable the rule, also you can define a time range when the rule is valid and number of usages.
For more details check here:
http://docs.magento.com/m1/ce/user_guide/marketing/price-rule-shopping-cart-buy-x-get-y-free.html

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