Skip to content

Instantly share code, notes, and snippets.

@Blair2004
Last active December 11, 2019 11:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Blair2004/1e70acbd294d03898260a14077e55ee3 to your computer and use it in GitHub Desktop.
Save Blair2004/1e70acbd294d03898260a14077e55ee3 to your computer and use it in GitHub Desktop.
<?php
$orderBuilder = new OrderReceiptBuilder( 30 ); // where 30 is the order id
$order = $orderBuilder->get();
// Looping Over Products
$order->products->each( function( $product ) {
$product->price;
$product->gross_price;
$product->tax;
$product->total_tax;
$product->name;
$product->quantity;
// a lot more are available
});
// Retreiving the customer
$order->customer;
// includes
/**
* ->name,
* ->surname
* ->email
* ->total_spend
* ->total_credit
* ->total_orders
* // and a lot more
**/
// Example
$order->customer->email;
// retreive delivery informations
$order->shipping;
/**
* output example
* {
* "id": "59",
* "ref_shipping": "0",
* "ref_order": "63",
* "name": "",
* "surname": "",
* "address_1": "",
* "address_2": "",
* "city": "",
* "country": "",
* "pobox": "",
* "state": "",
* "enterprise": "",
* "title": "",
* "price": "0",
* "email": "",
* "phone": ""
* }
**/
// Example
$order->shipping->address_1;
// Retreiving Store & Order specific informations
// includes columns from invoice & receipt settings
$order->options;
/**
* output example
*
* {
* "shop_name": "NexoPOS",
* "shop_email": "email@site.com",
* "shop_pobox": "11620",
* "shop_fax": null,
* "shop_details": "Cafe - Eatery - Work",
* "shop_street": "Store Stree 88",
* "shop_phone": "+237656988008",
* "shop_city": "Jakarta",
* "address_1": "Business Park Kebon Jeruk A11-12",
* "address_2": "Jl. Meruya Ilir Raya No.88",
* "order_id": "63",
* "order_note": "",
* "order_cashier": "admin",
* "order_code": "191210-001",
* "order_date": "2019-12-10 09:56:40",
* "order_updated": "2019-12-10 09:56:40",
* "customer_name": "Customer Account",
* "customer_phone": "0",
* "delivery_cost": "0",
* "delivery_address_1": "",
* "delivery_address_2": "",
* "city": "",
* "country": "",
* "name": "",
* "surname": "",
* "phone": "",
* "state": "",
* "vat_type": "item_vat",
* "vat_percent": "10",
* "receipt_column_1": "customer name : Customer Account \r\norder: 191210-001",
* "receipt_column_2": "Cashier : admin",
* "receipt_footer": "Harga sudah termasuk pajak \r\nWWW.MEALYARD.ID - WiFi CODE: mealadadisini"
* }
**/
// example
$order->options->receipt_column_1;
// Retrieve order taxes if the products taxes is used
// it's an array of taxes
$order->taxes;
/**
* Output example
* [
* [
* {
* "id": "2",
* "name": "NIR",
* "description": "",
* "rate": "3.5",
* "type": "",
* "fixed": "0",
* "ref_group": "0",
* "pos_calculation_type": "",
* "author": "2",
* "date_creation": "2019-06-21 17:11:09",
* "date_mod": "0000-00-00 00:00:00",
* "value": 0.22575,
* "total_tax": 0.22575
* },
* {
* "id": "1",
* "name": "NHIL TAX",
* "description": "",
* "rate": "2.5",
* "type": "",
* "fixed": "0",
* "ref_group": "0",
* "pos_calculation_type": "",
* "author": "2",
* "date_creation": "2019-06-21 17:10:55",
* "date_mod": "0000-00-00 00:00:00",
* "value": 0.19625,
* "total_tax": 0.19625
* }
* ]
*]
**/
// Retreive a list of payments
$order->payments;
/**
* output example
* [
* {
* "id": "50",
* "order_code": "191210-001",
* "amount": "14.29",
* "author": {
* "id": "2",
* "email": "carlosjohnsonluv2004@gmail.com",
* "pass": "b88acf15753f6b1d7c0f4195181204c94780d38fcbf2150d9d3e1116dfa843ea",
* "name": "admin",
* "banned": "0",
* "last_login": "2019-12-10 11:41:35",
* "last_activity": "2019-12-10 11:41:35",
* "last_login_attempt": "2019-12-10 11:00:00",
* "forgot_exp": null,
* "remember_time": null,
* "remember_exp": null,
* "verification_code": "",
* "ip_address": "127.0.0.1",
* "login_attempts": null
* },
* "date_creation": "2019-12-10 09:56:40",
* "payment_type": "cash",
* "operation": "incoming",
* "ref_id": null
* }
* ]
**/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment