Manual

giftcard.class.php

Market giftcards management

Usage:

{{lang:php}}
// INITIALIZATION
// constructor new giftcard($db, $user_id[, $extra = '1']);
$GC = new giftcard($DB, $_SESSION['user_id'], 'cid = 3'); // $DB is the object from sql class, $extra sets additional condition to users id

// CREATE GIFTCARD
$array['value'] = 5; // ammount in money or percent
$array['type'] = giftcard::Gift; // possible values giftcard::Gift, giftcard::Payment, giftcard::Refund
$array['percent'] = 1; // 1 or 0 (money)
$array['uses'] = 100; // optional giftcard's usages, defaults to 1
$array['lang'] = $GET['lang']; // optional, returns current lang if not set
$array['code'] = 'X100200300' // optional, returns random code if not set
$array['datestart'] = '2010-12-07 15:19:00'; // optional, defaults to NULL
$array['dateend'] = '2010-12-31 23:59:59'; // optional, defaults to NULL
$GC->create_card($array);

// USE CARD
// use_card($code, $value, $order_id = 0, $use_only_once = false)
$GC->use_card('X100200300', 15, 66); // uses giftcard 'X100200300' with ammount 15, relates with order ID 66

// DELETE CARD
$GC->delete_card($id);

// GET CARD
$GC->get_card($id); // returns giftcard array by ID

// RESTORE CARD
$GC->restore_card($history_id); // every card is stored to history at any action and can be restored
Try myPortal 2: