我會看看WC_Abstract_Order這兩個公共職能。
/**
* Get a formatted shipping address for the order.
*
* @return string
*/
public function get_formatted_shipping_address() {
if (! $this->formatted_shipping_address) {
if ($this->shipping_address_1 || $this->shipping_address_2) {
// Formatted Addresses
$address = apply_filters('woocommerce_order_formatted_shipping_address', array(
'first_name' => $this->shipping_first_name,
'last_name' => $this->shipping_last_name,
'company' => $this->shipping_company,
'address_1' => $this->shipping_address_1,
'address_2' => $this->shipping_address_2,
'city' => $this->shipping_city,
'state' => $this->shipping_state,
'postcode' => $this->shipping_postcode,
'country' => $this->shipping_country
), $this);
$this->formatted_shipping_address = WC()->countries->get_formatted_address($address);
}
}
return $this->formatted_shipping_address;
}
而且......
/**
* Calculate shipping total.
*
* @since 2.2
* @return float
*/
public function calculate_shipping() {
$shipping_total = 0;
foreach ($this->get_shipping_methods() as $shipping) {
$shipping_total += $shipping['cost'];
}
$this->set_total($shipping_total, 'shipping');
return $this->get_total_shipping();
}
希望這有助於
添
做了我的或喬希的回答幫助?如果是這樣,你能接受嗎?如果沒有,你是否想出了自己的解決方案?如果你做得很好,你應該把它寫在這裏供其他人找到。最好,蒂姆 – mpactMEDIA 2016-03-23 00:09:56