Ubercart Custom Price

mrfelton - October 21, 2008 - 16:53
uberbadge_3.gif

The initial idea of this module was to allow custom PHP code to be associated with a product in order to adjust the price of the product. The nature of allowing an admin to enter a block of PHP code to be executed though, allows for much more elaborate and potentially dangerous operations.

Upon installation, this module will add a Custom Code field to your products. Sample uses of this code block are:

$item->price = $item->price;

This will do nothing....but it goes in by default.
$item->price refers to the price before attribute adjustments.

if($item->qty > 5) {
  $item->price = [cost] * 1.1;
}

If more than 5 items are ordered, set the product price to a 10% mark-up of the product cost. Product tokens are exposed to this code so things like [cost], [sell_price], [weight], [weight-raw], etc. can be used.

if(date('j', time()) == '1') {
  $item->price = $item->price/2;
}

Half price on the first of each month.

For additional examples which use attributes for price calculations, refer to the Attribute Tokens module.

There are limitless things to do here, but if you are going to get complicated with it you might as well just write a useful module. This also makes no attempt to notify the customer of any of these adjustments, so you'll need to do so in the description of the product.

Thanks to cYu for the original code

Sponsored by CodeGobbler.

Developed by Tom (mrfelton) of Kirkdesigns.

Releases

Official releasesDateSizeLinksStatus
5.x-1.02008-Dec-117.12 KBRecommended for 5.xThis is currently the recommended release for 5.x.
Development snapshotsDateSizeLinksStatus
6.x-1.x-dev2009-Sep-277.52 KBDevelopment snapshotDevelopment snapshots are automatically regenerated and their contents can frequently change, so they are not recommended for production use.


 
 

Drupal is a registered trademark of Dries Buytaert.