Last active
August 29, 2015 14:13
-
-
Save WazzaJB/c6b2dffbeeea11b9e0bc to your computer and use it in GitHub Desktop.
Shopp Sample Handling
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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