Title: Vendor TX Code
Last modified: August 21, 2016

---

# Vendor TX Code

 *  Resolved [zane99](https://wordpress.org/support/users/zane99/)
 * (@zane99)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/vendor-tx-code/)
 * The vendor tx code that is delivered to SagePay used to list the order number
   prior to using this plugin which is perfect for everything else but it becomes
   quite difficult to distinguish orders without the order number in the Vendor 
   TX code. Where can i adjust this so it sends the order number in here as it used
   to do.
 * Thanks
 * [https://wordpress.org/plugins/sagepay-direct-for-woocommerce-payment-gateway/](https://wordpress.org/plugins/sagepay-direct-for-woocommerce-payment-gateway/)

Viewing 14 replies - 1 through 14 (of 14 total)

 *  Plugin Author [swicks](https://wordpress.org/support/users/swicks/)
 * (@swicks)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/vendor-tx-code/#post-4695654)
 * Hi
 * Within the file ds-sagepay-direct.php (version 0.1.7.0)
    line 592: `$this->add_param('
   VendorTxCode', $this->create_vendor_tx_code());` change to: `$this->add_param('
   VendorTxCode', $this->create_vendor_tx_code( $order_id ));`
 * line 1094:
 *     ```
       private function create_vendor_tx_code()
               {
                   $time_stamp = date("ymdHis");
                   $rand_num = rand(0,32000) * rand(0,32000);
                   return $this->vendor_name . "-" . $time_stamp . "-" . $rand_num;
               } // end create_vendor_tx_code
       ```
   
 * change to:
 *     ```
       private function create_vendor_tx_code( $order_id )
               {
                   $time_stamp = date("ymdHis");
                   return $this->vendor_name . "-" . $time_stamp . "-" . $order_id;
               } // end create_vendor_tx_code
       ```
   
 *  Thread Starter [zane99](https://wordpress.org/support/users/zane99/)
 * (@zane99)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/vendor-tx-code/#post-4695672)
 * Thanks ill give that a try now!
 *  Thread Starter [zane99](https://wordpress.org/support/users/zane99/)
 * (@zane99)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/vendor-tx-code/#post-4695778)
 * Hi there, this has not worked i am afraid.
 * any other suggestions?
 *  Plugin Author [swicks](https://wordpress.org/support/users/swicks/)
 * (@swicks)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/vendor-tx-code/#post-4695779)
 * It worked for me.
 * What errors are you getting, it will only work on new orders?
 *  Thread Starter [zane99](https://wordpress.org/support/users/zane99/)
 * (@zane99)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/vendor-tx-code/#post-4695780)
 * No errors and yes i have been checking it against orders placed since i updated
   the file.
 * It simply does not return the order number at the end of the sequence. I get 
   the vendor name-date-unknownnumber
 * then a sequence of numbers which means nothing to me and is not the 4 digit order
   number.
 *  Plugin Author [swicks](https://wordpress.org/support/users/swicks/)
 * (@swicks)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/vendor-tx-code/#post-4695782)
 * Are you using another plugin to generate the order number or are you using woocommerce’s
   order numbers (post numbers)?
 * Steve
 *  Thread Starter [zane99](https://wordpress.org/support/users/zane99/)
 * (@zane99)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/vendor-tx-code/#post-4695784)
 * [http://wordpress.org/plugins/woocommerce-sequential-order-numbers/](http://wordpress.org/plugins/woocommerce-sequential-order-numbers/)
 * ^^^^^ i have this plugin installed to ensure every order number is unique and
   follows on from the last
 *  Plugin Author [swicks](https://wordpress.org/support/users/swicks/)
 * (@swicks)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/vendor-tx-code/#post-4695786)
 * That be the problem then 🙂
 * It uses an ‘order number’ custom field to retain the sequential number – nice
   code/plugin.
 * I’ll take a look at implementing it into the vendor tx code.
 *  Thread Starter [zane99](https://wordpress.org/support/users/zane99/)
 * (@zane99)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/vendor-tx-code/#post-4695787)
 * If possible it would be great to keep this plugin active and maintain the vendor
   tx code with the order number in.
 * Would be more than appreciative if you found a solution! Also its a very common
   plugin for woocommerce users so hopefully will help others in the future 🙂
 *  Plugin Author [swicks](https://wordpress.org/support/users/swicks/)
 * (@swicks)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/vendor-tx-code/#post-4695809)
 * Try this:-
 * keep line 592 as it previously was:
    `$this->add_param('VendorTxCode', $this-
   >create_vendor_tx_code());`
 * change the function to this on line 1094
    :
 *     ```
       /**
               * generate a unique vendorTxCode
               */
               private function create_vendor_tx_code()
               {
                   global $woocommerce;
   
                   if ( version_compare( $woocommerce->version, '2.0.20', '>' ) )
                       $order_num = isset( $this->order->order_number ) ? $this->order->order_number : '';
                   else
                       $order_num = isset( $this->order->order_custom_fields[ '_order_number' ][0] ) ? $this->order->order_custom_fields[ '_order_number'][0] : '';
   
                   $order_num = empty( $order_num ) ? mt_rand( 0, 32000 ): $order_num;
   
                   $time_stamp = date("ymdHis");
                   return $this->vendor_name . "-" . $time_stamp . "-" . $order_num;
               } // end create_vendor_tx_code
       ```
   
 * thanks
 * Steve
 *  Thread Starter [zane99](https://wordpress.org/support/users/zane99/)
 * (@zane99)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/vendor-tx-code/#post-4695813)
 * Thanks! I have applied the changes and will test this tomorrow. Will post back
   with results!
 *  Thread Starter [zane99](https://wordpress.org/support/users/zane99/)
 * (@zane99)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/vendor-tx-code/#post-4695835)
 * To confirm – there have been no orders this weekend. Will update again tomorrow
   when orders come in.
 * Thanks
 *  Thread Starter [zane99](https://wordpress.org/support/users/zane99/)
 * (@zane99)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/vendor-tx-code/#post-4695843)
 * This did the trick! The correct order number is now displayed.
 * Thank you so much for your help.
 * i hope others can use this trick also.
 * Have rated the plugin highly!
 *  Plugin Author [swicks](https://wordpress.org/support/users/swicks/)
 * (@swicks)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/vendor-tx-code/#post-4695848)
 * Thank you – very much appreciated.

Viewing 14 replies - 1 through 14 (of 14 total)

The topic ‘Vendor TX Code’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/sagepay-direct-for-woocommerce-payment-
   gateway_8284e5.svg)
 * [WooCommerce SagePay Direct Payment Gateway](https://wordpress.org/plugins/sagepay-direct-for-woocommerce-payment-gateway/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/sagepay-direct-for-woocommerce-payment-gateway/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/sagepay-direct-for-woocommerce-payment-gateway/)
 * [Active Topics](https://wordpress.org/support/plugin/sagepay-direct-for-woocommerce-payment-gateway/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/sagepay-direct-for-woocommerce-payment-gateway/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/sagepay-direct-for-woocommerce-payment-gateway/reviews/)

 * 14 replies
 * 2 participants
 * Last reply from: [swicks](https://wordpress.org/support/users/swicks/)
 * Last activity: [12 years, 3 months ago](https://wordpress.org/support/topic/vendor-tx-code/#post-4695848)
 * Status: resolved