I am using CarthThrob and Sage Payments NA (Bank Card HTTPS) to process transactions. Using the standard Sage US payment gateway it does work, but I need to edit the Order ID (T_ordernum in the Sage docs) to include some items specific information. Right now it is the entry_ID plus a timestamp: 123_1234567890 which is meaningless in our system.

I'd like it to use some custom field data: account number and last name so orders appear in Sage as: 123_Lastname (maybe adding the timestamp for randomness).

I am capturing these as item_options in the add to cart form:


However the payment gateway creates the Order Number from the entry_id and Unix time:

'T_ordernum'=> $this->order('entry_id')."_" .time(),

I'd like to have it grab those item variables. I've added this (found in another payment gateway):

$reference = ''; 
    if (!empty($item['item_options']['account']))
        $reference .=$item['item_options']['account'] ."-"; 
    if (!empty($item['item_options']['last_name']))
        $reference .=$item['item_options']['last_name'] ."-"; 

The issue we (the php guy here...I'm more design/front end) have is getting $item info. We don't see where that is coming from.

I realize this is a longshot (did contact CartThrob but they are relaunching their site and been very busy the last few weeks). If it is an easy fix and you can post it here, great. If you want to do this for pay, I'm open to that as well (if that is not allowed here let me know and I'll remove this question).

1 Answer 1


You can access the order items as an array in the payment gateway:

$items = $this->order('items');

foreach ($items as $item) {
    echo $item['item_options']['foo'];
  • Thanks, we are looking into this today. We'll be sure to mark the answer once we get things working.
    – Doug
    Dec 19, 2012 at 18:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.