WordPress.org

Forums

WooCommerce SagePay Direct Payment Gateway
[resolved] Vendor TX Code (15 posts)

  1. zane99
    Member
    Posted 1 year ago #

    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/

  2. swicks
    Member
    Plugin Author

    Posted 1 year ago #

    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
  3. zane99
    Member
    Posted 1 year ago #

    Thanks ill give that a try now!

  4. zane99
    Member
    Posted 1 year ago #

    Hi there, this has not worked i am afraid.

    any other suggestions?

  5. swicks
    Member
    Plugin Author

    Posted 1 year ago #

    It worked for me.

    What errors are you getting, it will only work on new orders?

  6. zane99
    Member
    Posted 1 year ago #

    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.

  7. swicks
    Member
    Plugin Author

    Posted 1 year ago #

    Are you using another plugin to generate the order number or are you using woocommerce's order numbers (post numbers)?

    Steve

  8. zane99
    Member
    Posted 1 year ago #

    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

  9. swicks
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  10. zane99
    Member
    Posted 1 year ago #

    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 :)

  11. swicks
    Member
    Plugin Author

    Posted 1 year ago #

    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

  12. zane99
    Member
    Posted 1 year ago #

    Thanks! I have applied the changes and will test this tomorrow. Will post back with results!

  13. zane99
    Member
    Posted 1 year ago #

    To confirm - there have been no orders this weekend. Will update again tomorrow when orders come in.

    Thanks

  14. zane99
    Member
    Posted 1 year ago #

    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!

  15. swicks
    Member
    Plugin Author

    Posted 1 year ago #

    Thank you - very much appreciated.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.