Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Change Order Status Depending On Payment_Id Rate Topic   - - - - -

 
  • MichaelG
  • Newbie
  • Trial users
  • Join Date: 11-Apr 17
  • 1 posts

Posted 31 August 2018 - 09:59 AM #1

Hi,

 

I am trying to change a order status depending on a payment_id. But i can't get the payment_id inside a controller. When i am testing i can get the order id, but the payment_id returns returns 0.

 
What am i doing wrong? See example below.
 

Thanks in advange

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
   if ($mode == 'generate') {
        
        $order_id = empty($_REQUEST['order_id']) ? 0 : $_REQUEST['order_id'];
               
        $payment_id = db_get_field("SELECT payment_id FROM ?:orders WHERE order_id =?i", $_REQUEST['order_id']);
        
        $order_info = Tygh::$app['view']->getTemplateVars('order_info');
                
        $check_payment = array(12);
        
         if (in_array($order_info['payment_id'], $check_payment )) {
        fn_change_order_status($order_id, 'Q');
           fn_print_die($order_id, $check_payment ,$payment_id);
         } else {
         fn_change_order_status($order_id, 'C');
fn_print_die($order_id, $check_payment ,$payment_id);
         }




        return array(CONTROLLER_STATUS_OK, "orders.details?order_id=$order_id".$suffix);
    }
}

 



 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 17999 posts

Posted 31 August 2018 - 01:57 PM #2

Not sure what does the "generate" mode mean, but try the following code

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
   if ($mode == 'generate') {
        $order_id = empty($_REQUEST['order_id']) ? 0 : $_REQUEST['order_id'];

        $order_info = fn_get_order_info($order_id);;
          
        if (!empty($order_info['payment_id'])) {
            $check_payment = array(12);
        
            if (in_array($order_info['payment_id'], $check_payment )) {
                fn_change_order_status($order_id, 'Q');
                fn_print_die($order_id, $check_payment ,$payment_id);
            } else {
                fn_change_order_status($order_id, 'C');
                fn_print_die($order_id, $check_payment ,$payment_id);
            }
        }

        return array(CONTROLLER_STATUS_OK, "orders.details?order_id=$order_id".$suffix);
    }
}

GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    CS-Cart RU                         24500 руб.
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      CS-Cart RU + UniTheme    36000 руб.


 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 10838 posts

Posted 31 August 2018 - 08:01 PM #3

Each payment method passes the next order status in the payment method code ($pp_response['order_status']) so I'd suggest you edit the payment method if you want to alter it's behavior.


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.