Viewing 14 replies - 1 through 14 (of 14 total)
  • Plugin Author swicks

    (@swicks)

    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

    Thanks ill give that a try now!

    Hi there, this has not worked i am afraid.

    any other suggestions?

    Plugin Author swicks

    (@swicks)

    It worked for me.

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

    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

    (@swicks)

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

    Steve

    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

    (@swicks)

    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.

    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

    (@swicks)

    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

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

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

    Thanks

    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

    (@swicks)

    Thank you – very much appreciated.

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Vendor TX Code’ is closed to new replies.