woo-commerce change Item total as per quantity of item - wordpress

I want to create a woo-commerce plugin that will give a discount as per the quantity of product.
suppose, if price/roll is $1 and in one cartoon there are 36 rolls but cartoon price is $30 then when they add 36 rolls in qty price should be $30. Price for 2-5 cartoon and 6-9 cartoon is different but it in counting or in calculation we only consider the rolls, suppose 2-5 cartoon price is $0.9, if rolls are 100 then consider $0.9, 6-9 cartoon price is $0.8 and customer add 250 rolls then consider price $0.8.

Related

HERE-API wrong route cost on Poland

I am sending a request for a route with costs for a truck. Route Warsaw - Berlin, vehicle parameters
trucks
width 255 cm
height 256 cm
length 13.6 meters
weight 14 tons
number of axles 5
The costs received, unfortunately, due to the number of axles, the api calculates for a category 5 vehicle, see Price kat 5
which is wrong because a category 5 vehicle is a vehicle that meets any of the conditions
width > 255 cm
height > 400 cm
length > 16.5 meters
weight > 42t
The api correctly interprets only the height condition, at a time the API will overinterpret the number of axles which does not affect the category of the vehicle
For an inquiry in accordance with the vehicle parameters, I meet the requirements of the price list for category 4 see Price kat 4
Please help

Calculate Ageing of sold Inventory in R

Have a data frame with dates of transaction and units of the product, e.g.:
date_tr units
1/1/2022 +50
1/2/2022 +30
1/3/2022 -10
1/4/2022 -45
1/5/2022 +25
where + denotes bought and - denotes sold.
I need to find the ageing of the sold products in R. There are 1000s of products and 1000s of entries. Ideally need to convert to a data frame with corresponding bought dates eg:
1/1/2022 10 1/3/2022 10
1/1/2022 40 1/4/2022 40
1/2/2022 5 1/4/2022 5
My understanding of flifo package is it will help in finding the products in the inventory with fifo or lifo. But I need to find the ageing of the sold products, in R. Highly appreciate any help!

Woocomerce Points & Rewards Change Points Rewarded Upon Quantity Change

I Have installed Woocommerce Points & Rewards
Now the customer is rewarded with 5 points for 1 item purchased
However, I would like to reward 15 points for the same item purchased when the quantity increases to 2 units.
example:
purchase 1 item A = 5 points
purchase 2 items A = 15 points
How do I do this?

Join of two tables in prestoDB based on closest value

I have two tables, one with timeseries values and another one with prices. For example
timeseries
purchase_date user_id item_id
1618231488 123 2313
1618244875 435 2314
1618266985 23 2313
1618268671 54 144
...
price
item_id price_date price
2313 1618231400 233.67
2313 1618232400 294.12
2313 1618254400 224.14
144 1618254400 212.34
...
Goal: evaluate the price of each item purchased by a user at the given purchase timestamp.
As you can see from sample data, a purchase can happen at any timestamp, while the price of an item is stored every hour inconsistently. So, for example, we can have an item price updated every hour for one day and for the next day, maybe just a couple of updates. This happens because system records price only if there's a change.
Using an SQL query (engine is PrestoDB) and keeping in mind that the timeseries table can be of millions of rows (while the prices one up to a few hundreds thousands), how can I get a table as follows
timeseries_with_price
date user item price
1618231488 123 2313 xxx.xx
1618244875 435 2314 xxx.xx
1618266985 23 2313 xxx.xx
1618268671 54 144 xxx.xx
...
Where xxx.xx are the prices at given timestamp. Of course, item price doesn't change linearly but change when a new record is put in database. So if I have (simplifying timestamps for readability)
price at date 100 equal to 14.02$
price at date 300 equal to 23.02$
These are the transactions' prices based on purchase date:
purchase_date: 100 -> price 14.02$
purchase_date: 148 -> price 14.02$
purchase_date: 299 -> price 14.02$
purchase_date: 300 -> price 23.02$
purchase_date: 348 -> price 23.02$
You could do join of both tables based on item_id and then select only the elements that are closest in time, for example:
select purchase_date,
user_id,
item_id,
min_by(price, abs(purchase_date-price_date)) as price
from timeseries join price using(item_id)
group by purchase_date, user_id, item_id
See the docs for the min_by function here: https://prestodb.io/docs/current/functions/aggregate.html#min_by
I'm purposefully placing the price table to the right of the join since it's the smallest of the two. Ideally though, when a user makes a purchase you would keep a pointer to a unique identifier in the price table.

How can i calculate price from discount given by supplier in a purchase order?

I have a sample value as shown below
$item_A = $ 112.50 # 6% tax after tax = 9.25
$item_B = $ 10.00 # 0% tax
//I bought 2 item_A ($ 238.50) and 1 item_B ($ 10)
$sub_total = $ 235.00
$tax_amt = $ 13.50
$total = $ 248.50
At here i want to apply a discount $40 and then share among on the items price, which mean my total should be $208.75 after discounted.
discount will be based on setting either applied before or after tax of total amount
// formula to share among
$distribute = sub-total of item / total amount * discount
After get the $distribute, then will divide the quantity and add to the current unit price.
In this case, if i am recalculating the total amount, it will became lesser due to the unit price of item applied the discount.
My expected result is when applied $40 discount on $248.50, it will became $208.50 with a $40 discount applied even recalculate it.
is it need to remain the tax amount of the original price?
What is the solution to use to deal with this situation? Anyone can help and give suggestion on this case? Thanks.

Resources