Closed (fixed)
Project:
Ecommerce Node Access Product
Version:
5.x-1.0
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
27 Sep 2008 at 06:15 UTC
Updated:
11 Dec 2008 at 06:52 UTC
for this module to work with latest ecommerce (alpha 11) add this function to the module:
/**
Fix by Nabulaer
add support for ecommerce 4.x
*/
function ec_nodeaccess_ec_txn_workflow($txn, $orig) {
if($txn->workflow == EC_WORKFLOW_COMPLETED ){
$update_transactions = false; // only turn this to true if the transaction contains a Node Access Product
// Go through each of the products purchased.
$items = (array)$txn->items ;
for ($i = 0; $i < count($items); $i++) {
$node =& $items[$i]; // easy referencing
$settings = ec_nodeaccess_get_nap_settings($node->nid);
if ($settings != false) { //if the nid belongs to a NAP
$update_transactions = true;
if ($node->schedule['expiry']) { //if there is an expiry date
$expiry = strftime('%Y-%m-%d %H:%M:%S', $node->schedule['expiry']);
}
else { // no expiry date
$expiry = '7000-1-1 12:00:00';
}
if (db_query("INSERT INTO {ec_nodeaccess_purchases} (txn_id, product_nid, expiry_date) VALUES (%d, %d, '%s')", $txn->txnid, $node->nid, $expiry) == false) {
drupal_set_message("There was a database error. User ". ec_customer_get_uid($txn->customer) ." has not been given access by ec_nodeaccess. code: ENP", error);
}
}
}
if ($update_transactions) { //if the transaction contains a Node Access Product
if (db_query("INSERT INTO {ec_nodeaccess_transactions} (txn_id, uid, purchase_date) VALUES (%d, %d, '%s')", $txn->txnid, ec_customer_get_uid($txn->customer), strftime('%Y-%m-%d %H:%M:%S', $txn->changed)) == false) {
drupal_set_message("There was a database error. User ". ec_customer_get_uid($txn->customer) ." has not been given access by ec_nodeaccess. code: ENT", error);
}
}
}
}
Comments
Comment #1
danielb commentedThanks! Committed.