jrb/module-ordercontroller

To implement guest order history feature

dev-master 2018-10-10 14:26 UTC

This package is not auto-updated.

Last update: 2024-10-10 17:34:35 UTC


README

Decription

Implement guest order history feature with a new controller that takes parameter(s) to query a single order and returns a json with information about order status, total, items (sku, item_id, price) and total invoiced.

Installation

Composer Package

  1. Go to Magento® 2 root folder

  2. Enter following commands to install module:

    composer require jrb/module-ordercontroller dev-guestorderhistory
    

    Wait while dependencies are updated.

  3. Enter following commands to enable module:

    php bin/magento module:enable JRB_OrderController
    php bin/magento setup:upgrade
    php bin/magento cache:clean
    

Manually

  1. Go to Magento® 2 root folder

  2. paste all code in a foler app/code/JRB/OrderController

  3. Enter following commands to enable module:

    php bin/magento module:enable JRB_OrderController
    php bin/magento setup:upgrade
    php bin/magento cache:clean
    

How to use

by calling rest api

end point:

rest/V1/guestorder/getGuestOrderHistory/:param

param can be 1,2,.. all

<?php
 /*
  * init curl
  */
 /*
 $ch = curl_init();
  
 curl_setopt($ch,CURLOPT_URL,'http://hostname/rest/V1/guestorder/getGuestOrderHistory/1');
 curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
 curl_setopt($ch,CURLOPT_HEADER, false); 

 $output=curl_exec($ch);

 curl_close($ch);

 echo $output;
 ?>

or by calling simple controller

<?php
 /*
  * init curl
  */
 $ch = curl_init();  
  
 curl_setopt($ch,CURLOPT_URL,'http://hostname/ordercontroller/guestorderhistory?total_guest_order=1');
 curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
 curl_setopt($ch,CURLOPT_HEADER, false); 

 $output=curl_exec($ch);

 curl_close($ch);

 echo $output;
 ?>