Skip to content

Instantly share code, notes, and snippets.

@digitalchild
Created June 29, 2016 00:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save digitalchild/9db55198bc568c8488a0f2a8d1548292 to your computer and use it in GitHub Desktop.
Save digitalchild/9db55198bc568c8488a0f2a8d1548292 to your computer and use it in GitHub Desktop.
How we store shipping rates per product
<?php
for ( $i = 0; $i < $shipping_fee_count; $i ++ ) {
if ( $shipping_fees[ $i ] != '' ) {
$country = wc_clean( $shipping_countries[ $i ] );
$state = wc_clean( $shipping_states[ $i ] );
$fee = wc_format_decimal( $shipping_fees[ $i ] );
$shipping_rates[ $i ] = array(
'country' => $country,
'state' => $state,
'fee' => $fee,
);
}
}
update_post_meta( $product_id, ‘_wcv_shipping_rates’, $shipping_rates );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment