Click on [+], to show detailed description for array
|
---|
[ 'ORDER' => {Bitrix\Sale\Order}, // order object with attached receipt 'PAYMENTS' => [ // payment array [ 'ENTITY' => {Bitrix\Sale\Payment}, // payment object 'IS_CASH' => "N", // payment document type: cash/cashless (indicated for compatibility). // It's recommended to use field with TYPE key 'TYPE' => "cashless", // payment document type: accepts one of values: cash, //cashless, advance, credit 'SUM' => 1400, // payment document total sum ] ], 'PRODUCTS' => [ // list of product items [ 'ENTITY' => {Bitrix\Sale\BasketItem}, // shopping cart item object 'PRODUCT_ID' => "176", // product ID 'NAME' => "T-shirt Female Wonder", // name 'BASE_PRICE' => 849, // price without discounts and extra charges per item 'PRICE' => 1099, // price with discounts and extra charges per item 'SUM' => 1099, // total price per quantity 'QUANTITY' => 1, // quantity 'VAT' => 0, // tax rate ID 'DISCOUNT' => [ // discount data 'PRICE' => -250, // discount value (negative value - extra charge, //positive - discount) 'TYPE' => "C", // discount type: С-absolute ], 'PAYMENT_OBJECT' => \Bitrix\Sale\Cashbox\Check::PAYMENT_OBJECT_COMMODITY //payment item type* ] ], 'DELIVERY' => [ // list of deliveries [ 'ENTITY' => {Bitrix\Sale\Shipment}, // delivery object 'NAME' => "Delivery", // name 'BASE_PRICE' => 301, // price without discounts and extra charges per item 'PRICE' => 301, // price with discounts and extra charges per item 'SUM' => 301, // total price with per quantity 'QUANTITY' => 1, // quantity (always equals 1) 'VAT' => 1, // tax rate ID 'PAYMENT_OBJECT' => \Bitrix\Sale\Cashbox\Check::PAYMENT_OBJECT_SERVICE //payment item type* ] ], 'BUYER' => [ // buyer information 'EMAIL' => "admin-aladin@aladin.loc", // email 'PHONE' => "8-9900-1143-32255-1123", // phone number ], 'TOTAL_SUM' => 1400 // total receipt amount ]* - ключ PAYMENT_OBJECT available from version 18.5.10, with possible values:
|
Cash registers and receipts
Event | Description | Available from version |
---|---|---|
OnSaleCheckPrepareData | Allows modify specific data in a receipt: update product name, remove products with 0 cost and etc. Two parameters are passed on input:
// delete delivery with 0 price AddEventHandler("sale", "OnSaleCheckPrepareData", "CheckProductPrint"); function CheckProductPrint($a, $type) { if ($a['DELIVERY']['SUM'] == 0) unset($a['DELIVERY']); return $a; } | |
OnGetCustomCashboxHandlers | Event is triggered when building list of cash register handlers. Allows adding your own cash register handler.
// adding your own cash register AddEventHandler("sale", "OnGetCustomCashboxHandlers", "GetCustomCashboxHandlers"); function GetCustomCashboxHandlers() { $data = array('\Bitrix\Sale\Cashbox\cashboxnew' => '/bitrix/php_interface/include/cashboxnew.php'); $event = new Bitrix\Main\EventResult(Bitrix\Main\EventResult::SUCCESS, $data); return $event; } | |
OnGetCustomCheckList | Event is triggered when building list of supported receipts. Allows adding your own receipt.
// adding your own receipt type AddEventHandler("sale", "OnGetCustomCheckList", "GetCustomCheckList"); function GetCustomCheckList() { $data = array('\Bitrix\Sale\Cashbox\SellExCheck' => '/bitrix/php_interface/include/sellexcheck.php'); $event = new Bitrix\Main\EventResult(Bitrix\Main\EventResult::SUCCESS, $data); return $event; } | |
OnPrintableCheckSend | Event allows redefining standard notification mechanism for sending receipt print. Passes 2 parameters on input: payment object used to print the receipt and receipt object to be printed.
// re-defining standard receipt printing mechanism AddEventHandler("sale", "OnPrintableCheckSend", "PrintableCheckSend"); function PrintableCheckSend() { /* Send receipt via SMS */ $event = new Bitrix\Main\EventResult(Bitrix\Main\EventResult::SUCCESS); return $event; } | |
onSaleCashboxRestrictionsClassNamesBuildList | Event allows adding your own restrictions on cash registers.
onSaleCashboxRestrictionsClassNamesBuildList // adding your own receipt type AddEventHandler("sale", "onSaleCashboxRestrictionsClassNamesBuildList", "GetSaleCashboxRestrictionsClassNamesBuildList"); function GetSaleCashboxRestrictionsClassNamesBuildList() { $data = array( '\Bitrix\Sale\Cashbox\Restrictions\Site' => '/bitrix/php_interface/include/site.php' ); $event = new Bitrix\Main\EventResult(Bitrix\Main\EventResult::SUCCESS, $data); return $event; } | |
OnCheckCollateDocuments | Event is designed to implement custom logic for generating receipts in automatic mode.
Let's review an example: with order total more than 10000, a prepayment is charged. The remaining amount is charged after the order is checked by a manager. This process will have several payments. For the first payment, print an advance payment receipt, for the second payment - full payment with an advance. This example will look as follows: AddEventHandler("sale", "OnCheckCollateDocuments", "OnCheckCollateDocuments"); function OnCheckCollateDocuments($entities) { foreach ($entities as $entity) { if ($entity instanceof \Bitrix\Sale\Payment) { $order = $entity->getCollection()->getOrder(); if ($order->isPaid()) { $related = []; foreach ($entity->getCollection() as $payment) { if ($payment->getId() != $entity->getId()) { $related[\Bitrix\Sale\Cashbox\Check::PAYMENT_TYPE_ADVANCE][] = $payment; } } foreach ($order->getShipmentCollection() as $shipment) { if (!$shipment->isSystem()) { $related[\Bitrix\Sale\Cashbox\Check::SHIPMENT_TYPE_NONE][] = $shipment; } } return new \Bitrix\Main\EventResult( \Bitrix\Main\EventResult::SUCCESS, [['TYPE' => 'sell', 'ENTITIES' => [$entity], 'RELATED_ENTITIES' => $related]] ); } else { if ($entity->isPaid() && !$order->isPaid()) { return new \Bitrix\Main\EventResult( \Bitrix\Main\EventResult::SUCCESS, [['TYPE' => 'advancepayment', 'ENTITIES' => [$entity], 'RELATED_ENTITIES' => []]] ); } } } } } |
© «Bitrix24», 2001-2024