Change shipping cost based on checkout choice
-
I have a plugin which is creating a local storage entry and when you change the input choice it changes the local storage value. I want to adjust my shipping cost based on this but the code I have isn’t doing anything. I outputted the local storage value elsewhere test I was actually getting it with php and it is correct. But in this context it doesn’t work.
add_filter( 'woocommerce_package_rates', 'woocommerce_package_rates' ); function woocommerce_package_rates( $rates ) { $myvar = "<script>document.write(localStorage.getItem('delivery date'))</script>"; if ( $myvar == '29-6-2022') { $test = 100; } else { $test = 5; } foreach($rates as $key => $rate ) { $rates[$key]->cost = $rates[$key]->cost + $test; } return $rates; }
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Change shipping cost based on checkout choice’ is closed to new replies.