无意中发现了这件事,我现在发现了同样的东西(Woocommerce 3.x)。。。
add_filter( \'woocommerce_checkout_create_order\', \'mbm_alter_shipping\', 10, 1 );
function mbm_alter_shipping ($order) {
if ($something == $condition) {
$address = array(
\'first_name\' => \'Martin\',
\'last_name\' => \'Stevens\',
\'company\' => \'MBM Studio\',
\'email\' => \'[email protected]\',
\'phone\' => \'777-777-777-777\',
\'address_1\' => \'99 Arcadia Avenue\',
\'address_2\' => \'\',
\'city\' => \'London\',
\'state\' => \'\',
\'postcode\' => \'12345\',
\'country\' => \'UK\'
);
$order->set_address( $address, \'shipping\' );
}
return $order;
}