SMFHacks.com

SMF Store => Support => Topic started by: KKOG on November 30, 2017, 11:01:53 pm

Title: Transaction ID on Packing Slip Incorrect
Post by: KKOG on November 30, 2017, 11:01:53 pm
Hi,

We currently have a problem that the transaction id on the packing slip is different to the actual transaction id.

All the other information on the packing slip is correct.

This difference may have been caused by activities undertaken during the initial setup and testing.

How is the transaction id sourced for the packing slip?  There appears to be a database query at line 9900 of store2.php.  Is this the query, if so how is the transaction id being returned incorrectly?

Thanking you in anticipation of your help

Greg Ralph
KKOG Forum Admin
Title: Re: Transaction ID on Packing Slip Incorrect
Post by: KKOG on December 01, 2017, 12:34:16 am
I see the transaction id is printed at the following

9870      echo $txt['store_trans_txn_id'] . ': ' . $transRow['id_trans'];

with id_trans defined in a query at line 9806.

The rest of the detail in the packing slip is defined using a query based on the store_basketid in line 9883

Somehow there seems to be a mismatch in the data retrieved

Regards
Greg Ralph
KKOG Forum Admin
Title: Re: Transaction ID on Packing Slip Incorrect
Post by: SMFHacks on December 01, 2017, 10:29:32 pm
Made change for next update hotfix/change

Open Sources/Store2.php
Line 9803
Find
Code: [Select]
$context['store_basketid'] = $id;

$dbresult = $smcFunc['db_query']('', "
SELECT 
is_subscription, is_custompaypal, custom, cart_items,
totalprice, totalshipping, totaltax, currency, date, id_trans,
weight_unit, weight_total, notes, is_shipped, completed
FROM {db_prefix}store_basket   
WHERE ID_BASKET = " . $context['store_basketid'] . " LIMIT 1" );
$basketRow = $smcFunc['db_fetch_assoc']($dbresult);
$smcFunc['db_free_result']($dbresult);

$dbresult = $smcFunc['db_query']('', "
SELECT id_trans, txn_id
FROM ({db_prefix}store_transactions)
WHERE ID_BASKET = " . $context['store_basketid']. " LIMIT 1");
$transRow = $smcFunc['db_fetch_assoc']($dbresult);

Change to
Code: [Select]
$context['store_basketid'] = $id;

$dbresult = $smcFunc['db_query']('', "
SELECT 
is_subscription, is_custompaypal, custom, cart_items,
totalprice, totalshipping, totaltax, currency, date, id_trans,
weight_unit, weight_total, notes, is_shipped, completed
FROM {db_prefix}store_basket   
WHERE ID_BASKET = " . $context['store_basketid'] . " LIMIT 1" );
$basketRow = $smcFunc['db_fetch_assoc']($dbresult);
$smcFunc['db_free_result']($dbresult);

$dbresult = $smcFunc['db_query']('', "
SELECT id_trans, txn_id
FROM ({db_prefix}store_transactions)
WHERE ID_BASKET = " . $context['store_basketid']. " LIMIT 1");
$transRow = $smcFunc['db_fetch_assoc']($dbresult);

if (!empty($transRow['txn_id']))
$transRow['id_trans'] = $transRow['txn_id'];

Title: Re: Transaction ID on Packing Slip Incorrect
Post by: KKOG on December 02, 2017, 12:29:31 am
Hi,

I made the code change but the Transaction ID on the packing slip was not correct.

Attached is an image of the transaction showing the transaction id, an image of the packing slip transaction id prior to the code change and an image of the packing slip transaction id after the code change

Cheers
Greg Ralph
KKOG Forum Admin
Title: Re: Transaction ID on Packing Slip Incorrect
Post by: SMFHacks on December 02, 2017, 01:52:17 pm
You want to show the order number from the basket id?
If so then use the following instead
Code: [Select]
$context['store_basketid'] = $id;

$dbresult = $smcFunc['db_query']('', "
SELECT 
is_subscription, is_custompaypal, custom, cart_items,
totalprice, totalshipping, totaltax, currency, date, id_trans,
weight_unit, weight_total, notes, is_shipped, completed
FROM {db_prefix}store_basket   
WHERE ID_BASKET = " . $context['store_basketid'] . " LIMIT 1" );
$basketRow = $smcFunc['db_fetch_assoc']($dbresult);
$smcFunc['db_free_result']($dbresult);

$dbresult = $smcFunc['db_query']('', "
SELECT id_trans, txn_id
FROM ({db_prefix}store_transactions)
WHERE ID_BASKET = " . $context['store_basketid']. " LIMIT 1");
$transRow = $smcFunc['db_fetch_assoc']($dbresult);


$transRow['id_trans'] = $id;
Title: Re: Transaction ID on Packing Slip Incorrect
Post by: KKOG on December 02, 2017, 06:28:54 pm
Thank you, the latest code achieves what I was seeking.  Sorry for not explaining more clearly what I was trying to achieve. 

I have also changed the text in Store.English.php to read Order Number on the packing slip as the Order Number is referenced in the personal message sent to the customer when the product is shipped.  The changes were made because both the customer and the store administrator were looking to the Order Number as the reference for the transaction.

Thank you again for your help

Greg Ralph
KKOG Forum Admin