Skip to content

Instantly share code, notes, and snippets.

@strangerstudios
Last active August 29, 2015 14:11
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 strangerstudios/09df1c61ce56b15e78c9 to your computer and use it in GitHub Desktop.
Save strangerstudios/09df1c61ce56b15e78c9 to your computer and use it in GitHub Desktop.
Add S&H price based on shipping country given using PMPro and PMPro Shipping.
/*
Add S&H price based on shipping country given.
*/
function sh_pmpro_checkout_level($level)
{
//only for level 2
if($level->id != 2)
return $level;
//check shipping country
if(!empty($_REQUEST['sameasbilling']))
$country = $_REQUEST['bcountry'];
elseif(!empty($_REQUEST['scountry']))
$country = $_REQUEST['scountry'];
else
$country = "US"; //assume US
if($country == "US")
$level->initial_payment = $level->initial_payment + 12.95;
else
$level->initial_payment = $level->initial_payment + 24.95;
return $level;
}
add_filter('pmpro_checkout_level', 'sh_pmpro_checkout_level');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment