• Resolved rddavid

    (@rddavid)


    Hello,

    I have a problem concerning the cost for shipping. I would like the cost to be

    Max(12-0.2*[cost],0),

    that is the shipping cost starts at 12$ and decreases by 20¢ for every additional dollar in the order, but can not decrease below 0$ (the shipping cost should be 0$ for any order of more than 60$).

    However, it seems this is not the correct way to write the Max function. I tried any natural way to write the function I could find, but none seem to work. After browsing the web for some time, I still haven’t found the right way, if there is any.

    Thank you in advance,
    Best regards,
    David R.D.

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Maths is handled by:
    woocommerce/includes/libraries/class-wc-eval-math.php
    The allowed operators are + – * / and ^, so pretty basic, and no functions. max() is not supported.

    You may be able to do something with the filter: ‘woocommerce_evaluate_shipping_cost_args’.

    Thread Starter rddavid

    (@rddavid)

    Thank you for your kind answer.

    Plugin Support Hannah S.L.

    (@fernashes)

    Automattic Happiness Engineer

    If you don’t want to get into the code, then I can recommend our Table Rate Shipping plugin:
    https://www.woocommerce.com/products/table-rate-shipping/

    You’d be able to set up that max option, though it would be more UI based rather than pure math.

    Plugin Support Hannah S.L.

    (@fernashes)

    Automattic Happiness Engineer

    We haven’t heard back from you in a while, so I’m going to mark this as resolved – if you have any further questions, you can start a new thread.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Max function in shipping cost’ is closed to new replies.