Skip to content

Instantly share code, notes, and snippets.

@WazzaJB
Last active December 28, 2015 01:39
Show Gist options
  • Save WazzaJB/7422038 to your computer and use it in GitHub Desktop.
Save WazzaJB/7422038 to your computer and use it in GitHub Desktop.
Handling Shopp's shipping method selector in the cart. I couldn't find a decent action to hook into where 'is_cart_page()' also returned true, meaning that you can effectively have the shipping selector anywhere, although I have no idea what this will do - best just putting it in the cart ey ;)
<?php
/
*
ADD THIS CODE TO YOUR FUNCTIONS.PHP
*/
add_action('shopp_init', 'shopp_cart_shipping_handling');
function shopp_cart_shipping_handling( )
{
if ( array_key_exists('shipmethod', $_POST) )
{
$Shiprates = ShoppOrder()->Shiprates;
$ShippingAddress = ShoppOrder()->Shipping;
if ( !$Shiprates->disabled() )
{
if ( empty($ShippingAddress) )
$ShippingAddress = new ShippingAddress();
$selection = $_POST['shipmethod'];
if ( $selection != $Shiprates->selected()->slug )
{
// Verify shipping method exists first
if ( $Shiprates->exists($selection) )
{
$selected = $Shiprates->selected( $selection );
$ShippingAddress->option = $selected->name;
$ShippingAddress->method = $selected->slug;
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment