0

I am building an Aramex Shipping Plugin for WooCommerce Shopping Cart. I can set the calculated amount by using the add_rate method, but if there is any Error Response from the API, I am not able to show this message in the WooCommerce checkout.

Is there any way to show string messages in the WooCommerce checkout?

4

1 回答 1

0

您可以wc_add_wp_error_notices用于设置错误消息。

这个例子

if ($response) {
$rate = array(
    'id' => $this->id,
    'label' => 'Label for Shipping Method',
    'cost' => 10
);
// Register the rate
$this->add_rate($rate);

} else {
wc_add_wp_error_notices(new WP_Error(1,'error in get response from webservice'));

}
于 2015-10-20T21:06:19.650 回答