Skip to content

Instantly share code, notes, and snippets.

@WazzaJB
Last active August 29, 2015 14:13
Show Gist options
  • Save WazzaJB/c6b2dffbeeea11b9e0bc to your computer and use it in GitHub Desktop.
Save WazzaJB/c6b2dffbeeea11b9e0bc to your computer and use it in GitHub Desktop.
Shopp Sample Handling
<?php
class ShoppSampleHandler {
function __construct()
{
// If the sample post/get variable exists
if( isset($_REQUEST['sample-request']) )
{
// Hook into the action which adds it to cart
add_action( 'shopp_cart_before_add_item', array( &$this, 'manipulateSampleInfo' ) );
}
}
public function manipulateSampleInfo( $Item )
{
// Prpend sample of to the name
$Item->name = __('Sample of', 'shopp') . ' - ' . $Item->name;
// Modify the price
$Item->unitprice = (float) 1.0;
return;
}
}
new ShoppSampleHandler;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment