How can I add weight units to my quantity in woocommerce? - wordpress

I would like to add a weight quantity input field on product pages that allow customer to change the item weight by clicking on a plus or minus buttons. For example, you want to buy 1.25kg of tomatoes. For that, you can just click the plus icon until it reaches 1.25kg or you can type 1.25 kg. Here is an example of what I am looking for (this one does not have the ability to insert your quantity though).
Currently, I have used the plugins WPC Product Quantity and WooCommerce Price Per Unit PRO, but the problem is that it does not show the "kg" unit after the quantity number. You can have a look at that over here
Is there a plugin or a custom code that I can insert to fix this issue?
Note: I have products, which use units "kg" and "tk". So the code/plugin should be able to fix this issue on a product basis. "tk" just means "piece" in Estonian.

You may try to change the quantity box from integer datatype to float/double datatype, So the customer can place float number like 0.25 or 0.5,
you can use settype($var,"double"); in your code.
if the kg is not showing you also can use concatenate to add "kg" to your return value.
you return your value with concatenate by adding this to the end of your return value:
. " kg"

Related

Woocommerce not diplaying correct price with "Math Formula"

I'm using WooCommerce and also I'm using "Global Extra Product Options".
I'm trying to calculate a custom price based on two "date field".
In the second field I set as price the result of the following formula:
abs((({this.value}-{date1.value})/1000000)*{product_price})
I can't use datediff() so I had to be creative on how to get the number of days between two day (hence the /1000000).
Using this formula on the product page the price is display correctly (eg. for two days it would display € 2Price).
When I go to the my cart the final price is deducted by a value equal to the previously calculated price for field2.
(eg. the final price would be: € FinalPrice - € 2Price)
I'm messing around with the options but I can't find a solution, am I doing something wrong?

Woocommerce: How to change the item cost when editing orders?

I have default prices set for every product in the shop, but sometimes we agree on different prices per item with certain distributors, so I edit the prices in the order creation.
When editing, I would like to display the agreed price per item in the item_cost td and get the totals calculated in consecuence rather than editing the totals and getting the discount applied.
I thought this was a base feature of Woocommerce but apparently it isn't. Any ideas?
After so many time looking for a solution for the same problem, the support from Rednao team juste gave me the answer.
The light gray "before discount" field ("antes del descuento" in your case) is editable!
So just add your new price in the total field, add the same price in the "before discount" field, and that's it. The unit price will be OK now.

How to keep Wooccommerce Composite Product extension from multiplying the quantity of composite items by the base product quantity?

The Wooccommerce Composite Product extension allows you to create one product which is the combination of a base product and one or more component products. It's like having one or more small boxes inside one big box and the one big box inside an even bigger box. The quantities of the small boxes inside the one big box can be increased, and the quantity of the one big box can also be increased, but the even bigger box is the resulting product.
I have a base product (skateboard), and I have component products (trucks, wheels, etc.) that can be optionally added to the overall order. The quantities of the component products can be increased, same as the quantity of the base product.
The problem is when the quantity of the base product is increased, the quantity of the component product is multiplied by the the amount of the base product quantity, resulting in a larger quantity of component product being added to the cart.
Example: I want to order two skateboards and TWO trucks for the board. When I click the 'Add To Cart' button, the plugin calculates the price of two boards and FOUR trucks.
Here is a link to the Composite Product
Here is a link to the order results in the cart page
The resulting total should be $60 = (2x$10)+(2x$20),
NOT $100 = 2[(2x$20)+$10]
I found the solution to this problem. To do so, I had to modify the code in the class-wc-cp-cart.php file located in the includes folder. Had to divide the composite component quantity by the base product quantity in two places.
Line 432:
$quantity = $item_quantity * $composite_quantity/$item_quantity;
Line 1184:
$quantity = $composited_product->is_sold_individually() ? 1 : $item_quantity * $composite_quantity/$item_quantity;

WooCommerce : set TAX on product page

I'd like to set a specific Tax on each product.
I see i can create tax classes, but i'm going to have many different taxes, one per product, on more than 300 products.
Is it possible to set the tax % on the product page when i create it ?
Do you know a plugin for that ?
What want to do is to calculate Tax Based On SKU and not shipping address.
So i need to have a field on product page where i can enter a TVA number, manually.
Do you think it's possible ?
OR an other way maybe :
- have one taxe class
- in the tax class add many taxes rates with all the same country code, and no zip code
- create a field in the product page to assign the right tax rate for the product (instead of assign a class rate)
What do you think about that ?

WooCommerce: Date as attribute term

I'm relatively new to using WooCommerce so all advice would be great.
I've got a number of inclass training course products I'm trying to sell. Each have multiple date offerings.
Is there a way I can set the attribute term to a date value or do I have to manually add every possible date?
Is there another way to solve this problem, I am just ignorant off?
Thank you!
When you add the products and while entering the product data in general tab you will see two fields REGULAR PRICE & SALE PRICE beside the SALE PRICE text box you will see the schedule click on it you will find the DATE fields from Date to Date variations in price you can set it from there. Here I set an Image
Here you will Find the date fields to set

Resources