Support » Plugin: MarketPress - WordPress eCommerce » Numeric orders fails on creation from payment gateway

  • Resolved olekeh

    (@olekeh)


    Sometimes the generated order numbers consist of only digits. Those orders fail to be created from the payment gateway.

    The problem is in the class MP_Order – The constructor expects a $order parameter. It checks if the given order number is_numeric() to decide if its an order-id or an order number. As most order-numbers are like hexadecimal numbers, this works fine in most cases. However, sometimes it is generated a number with only digits in it, where this constructor fails.

    The Payment gateway, creates the order given the order-number from the $_POST, and do:

    $order = new MP_Order( $mp_order_num );

    then the constructor fails:

    	public function __construct( $order = null ) {
    		if ( ! is_null( $order ) ) {
    			if ( $order instanceof WP_Post ) {
    				$this->ID = $order->ID;
    			} elseif ( is_numeric( $order ) ) {
    				$this->ID = $order;
    			} else {
    				if( ! is_object( $order ) ) {
    					$this->_order_id = $order;
    				}
    			}
    
    			$this->_get_post();
    		} else {
    			$this->_generate_id();
    		}
    	}

    checking the parameter is_numeric( $order ).

    Instead of changing the constructor – I have made a change to the _generate_id() instead to ensure it always creates order-numbers that is not numeric.

    https://pasteboard.co/HvVP534.png

    Here is the patch:

    https://pastebin.com/wSX36ajj

Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Numeric orders fails on creation from payment gateway’ is closed to new replies.