function oncheckout($invoiceitem) { global $DB; if ($ii = $DB->get_record('invoiceitem', array('id' => $invoiceitem->id), '*')) { if ($block = get_license_block($ii->invoiceableitemid, $ii->license_allocation)) { $ii->currency = $block->currency; $ii->price = $block->price; $ii->license_validlength = $block->validlength; $ii->license_shelflife = $block->shelflife; $DB->update_record('invoiceitem', $ii); } } }
$basket->id = $DB->insert_record('invoice', $basket, true); $SESSION->basketid = $basket->id; } } else { $basket = new stdClass(); $basket->userid = $USER->id; $basket->status = INVOICESTATUS_BASKET; $basket->date = time(); $basket->id = $DB->insert_record('invoice', $basket, true); $SESSION->basketid = $basket->id; } $invoiceitem = new stdClass(); $invoiceitem->invoiceid = $basket->id; $invoiceitem->invoiceableitemid = $courseid; if ($nlicenses) { if ($block = get_license_block($courseid, $nlicenses)) { $invoiceitem->currency = $block->currency; $invoiceitem->price = $block->price; $invoiceitem->invoiceableitemtype = 'licenseblock'; $invoiceitem->license_allocation = $nlicenses; $invoiceitem->license_validlength = $block->validlength; $invoiceitem->license_shelflife = $block->shelflife; } } else { // Single purchase. if ($course = $DB->get_record('course_shopsettings', array('courseid' => $courseid), '*', MUST_EXIST)) { $invoiceitem->currency = $course->single_purchase_currency; $invoiceitem->price = $course->single_purchase_price; $invoiceitem->invoiceableitemtype = 'singlepurchase'; $invoiceitem->license_allocation = 1; $invoiceitem->license_validlength = $course->single_purchase_validlength;