'Triggering PHP hook for free shipping
I use a plugin in order to have a custom field at checkout that allows clients to pick some time intervals for delivery or pickup.
In woocommerce i have set up a flat rate for delivery and a free shipping over some amount.
Because my php skills are lacking i want help triggering free shipping when the pickup method is chosen from the custom checkout field, disregarding the amount in the cart.
After some digging online i know that in order to make the free shipping available again, i can use the filter
woocommerce_shipping_free_shipping_is_available
Now i have to 2 php folders in which i think this hook should go, or the child theme. One is the code in which delivery option is declared and one in which is checking if delivery pick up class exists so it can declare the time slots, etc.
In option 1:
if( !class_exists( 'custom_Delivery_Option' ) ) {
class custom_Delivery_Option {
.
. .
.
$delivery_option['delivery'] = __( $delivery_field_label, 'custom-delivery' );
$delivery_option['pickup'] = __( $pickup_field_label, 'custom-delivery' );
return $delivery_option;
}
}
And in option 2:
if( !class_exists( 'custom_Delivery_Pickup_Option' ) ) {
class custom_Delivery_Pickup_Option {
.
.
.
and then returns a result for the format with the day and time selected
Hope i gave all the information needed, if not please ask what should i share, once again i have a limited understanding of the php syntax.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
