admin管理员组

文章数量:1328548

I am using a third-party shipping plugin. Sometimes, this plugin somehow acts up, and only charges the client something like 1$.

I'd like to add a sanity check before the order is accepted, that the shipping amount should at least be e.g. 3$.

It seems that I should hook into woocommerce_after_checkout_validation to do this there.

But the shipping amount doesn't seem to be in $_POST - the only thing of interest is maybe 'shipping_method', but there's no amount to be seen (i just used flat rate as a test):

["shipping_method"]=>
  array(1) {
    [0]=>
    string(11) "flat_rate:4"
  }

How can I look up how much shipping is planned to being charged on the order that has just been submitted?

I am using a third-party shipping plugin. Sometimes, this plugin somehow acts up, and only charges the client something like 1$.

I'd like to add a sanity check before the order is accepted, that the shipping amount should at least be e.g. 3$.

It seems that I should hook into woocommerce_after_checkout_validation to do this there.

But the shipping amount doesn't seem to be in $_POST - the only thing of interest is maybe 'shipping_method', but there's no amount to be seen (i just used flat rate as a test):

["shipping_method"]=>
  array(1) {
    [0]=>
    string(11) "flat_rate:4"
  }

How can I look up how much shipping is planned to being charged on the order that has just been submitted?

Share Improve this question asked Jul 20, 2020 at 23:29 Moritz von SchweinitzMoritz von Schweinitz 101
Add a comment  | 

1 Answer 1

Reset to default 0

Found it!

global $woocommerce;

$shipping_method = $_POST['shipping_method'][0];
$shipping_amount = $woocommerce->cart->get_shipping_total();

本文标签: woocommerce offtopiccheck shipping amount in woocommerceaftercheckoutvalidation