I am creating a custom delivery method for Woocommerce, and one thing I am completely hung up on is to pass the custom values ββto the calculate_shipping () function when it is used on the Cart page or on the Checkout page.
I need to pass in a few user-defined variables that will affect the quote, that is, βIs the address live,β βIs the exhibition,β etc. etc.
calculate_shipping gets the $ package array, which contains the 'destination' array, but this only includes the standard data add1, add2, city, state, zip, country. I have added custom fields to the verification page for both billing and delivery, but I still cannot figure out how to make these values ββavailable to the calculate_shipping function.
I added a custom field, for example:
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
function custom_override_checkout_fields( $fields ) {
$fields['shipping']['is_residential'] = array(
'label' => __('Residential Address?', 'woocommerce'),
'type' => 'checkbox',
'required' => false,
'class' => array('form-row-wide'),
'clear' => true
);
return $fields;
}
And I see that this field is displayed in the "Delivery" section of the statement form. However, I do not see how I can access it anywhere. Even the execution print_r($_POST)on the validation page does not display this field as part of the message data, even after I know that the form has been updated and resubmitted.
, $package, Woocommerce calculate_shipping().
, .