Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
142 views
in Technique[技术] by (71.8m points)

php - Woocommerce estimated delivery based on products (addition)

I made an e-shop based on Woocommerce for my wife, but I've been solving one thing for a few months that I don't know how to solve. There is probably no plugin to help me, so I'm asking you.

We offer several types of products (for example two types):
#P1 - fabric headband (production of fabric headband is: 8 days) ID:1
#P2 - wool headband (production of wool headband is: 25 days) ID:2

Result:
At the shopping cart or checkout I need to inform the buyer how long the headbands will be made (e.g. based on CATEGORY ID)

Check image for idea:
img: sample shopping cart

And what I need?
-> if someone buys ... >=1 AND =<3 ... #P1 (fabric) show 8 days
-> if someone buys ... >=4 AND =<5 ... #P1 (fabric) show 9 days
-> if someone buys ... >=6 ... #P1 (fabric) show 10 days

same for wool
-> if someone buys ... 1x #P2 (wool) show 25 days
-> if someone buys ... 2x #P2 (wool) show 26 days
...
-> if someone buys ... >=6 #P2 (wool) show 30 days
etc. etc.

-> if someone buys combination of 1x #P1 (fabric) + 1x #P2 (wool) show 25 days
etc. etc.

What I have?
I have a solution that is created only by javascript and the number of pieces is entered by the customer manually on a special page.

I have special calculator
czech lang web: live example

Part of JS

if (((fabric >= 1) && (fabric <= 3)) && (wool == 0)) days = 8;
if (((fabric >= 4) && (fabric <= 5)) && (wool == 0)) days = 9;
if ((fabric >= 6) && (wool == 0)) days = 10;
if ((fabric == 0) && (wool == 1)) days = 25;
if ((fabric == 0) && (wool == 2)) days = 26;
if ((fabric == 0) && (wool == 3)) days = 27;
if ((fabric == 0) && (wool == 4)) days = 28;
if ((fabric == 0) && (wool == 5)) days = 29;
if ((fabric == 0) && (wool >= 6)) days = 30;
if (((fabric >= 1) && (fabric <= 3)) && (wool == 1)) days = 28;
if (((fabric >= 1) && (fabric <= 3)) && (wool == 2)) days = 29;
if (((fabric >= 1) && (fabric <= 3)) && (wool == 3)) days = 30;
if (((fabric >= 1) && (fabric <= 3)) && (wool == 4)) days = 31;
if (((fabric >= 1) && (fabric <= 3)) && (wool == 5)) days = 32;
if (((fabric >= 1) && (fabric <= 3)) && (wool >= 6)) days = 33;
if ((fabric >= 4) && (wool == 1)) days = 30;
if ((fabric >= 4) && (wool == 2)) days = 31;
if ((fabric >= 4) && (wool == 3)) days = 32;
if ((fabric >= 4) && (wool == 4)) days = 33;
if ((fabric >= 4) && (wool == 5)) days = 34;
if ((fabric >= 4) && (wool >= 6)) days = 35;

Soooooooo...

I would like the customer not to have to enter anything and check manually on special page. I would like the result to be displayed automatically based on the contents and goods amount of the cart (based on name of category or id category).

----

Is there a good soul who can write a simple function?
Big thanks for any help...


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...