Working with sale.personal.order and sale.personal.order.list in Bitrix
Rus
Eng
Работа с sale.personal.order и sale.personal.order.list в Битрикс

All English-language materials have been translated fully automatically using the Google service

List all orders in sale.personal.order.list, including canceled ones

It is enough to place the code before calling the component:

$_REQUEST<'show_all'>='Y'; 

Getting the order property for D7

  use Bitrix \ Sale \ Internals \ OrderPropsValueTable;

$ obProps = OrderPropsValueTable :: getList (array ('filter' => array ('ORDER_ID' => $ orderId, 'CODE' => 'PROPERTY_CODE')));
while ($ prop = $ obProps-> Fetch ()) {
$ arResult ['ORDERS'] [$ key] ['ORDER'] ['ADDITIONAL'] [$ prop ['CODE']] = $ prop ['VALUE'];
}  

Emptying the Bitrix shopping cart before repeating the order

Let's say we want the sale.personal.order.list component to empty the cart before using the "Repeat order" button

The easiest way is to enable CNC support in the component (the page will be auto-updated) and add a condition before calling the component

  if ($ _ REQUEST ['COPY_ORDER'] == 'Y') {// Check that the COPY_ORDER parameter was passed
// Empty the trash completely
    CSaleBasket :: DeleteAll (CSaleBasket :: GetBasketUserID ()); // Auto-detect the cart user and clear it

// Option with saving pending and expected goods
$ res = CSaleBasket :: GetList (array (), array (
                              'FUSER_ID' => CSaleBasket :: GetBasketUserID (),
                              'LID' => SITE_ID,
                              'ORDER_ID' => 'null',
                              'DELAY' => 'N',
                              'CAN_BUY' => 'Y'));
while ($ row = $ res-> fetch ()) {
CSaleBasket :: Delete ($ row ['ID']);
}
}  

Working with order status

Getting order status

  $ order = Bitrix \ Sale \ Order :: load ($ order_id);

$ order-> getField ('STATUS_ID');

// Most common statuses
$ STATUS_ID = array (
'F' => 'Completed',
'N' => 'Waiting for payment',
'P' => 'Paid'
);  

Order status change

  CSaleOrder :: StatusOrder ($ order_id, 'F'); // Done  

Set order status "Paid"

  CSaleOrder :: PayOrder ($ order_id, "Y"); // status paid (Y / N)  

Find out if the order has been canceled

  $ order = Bitrix \ Sale \ Order :: load ($ order_id);

$ order-> getField ('CANCELED'); // order canceled (Y / N)
$ order-> getField ('EMP_CANCELED_ID'); // ID of the user who canceled the order
$ order-> getField ('DATE_CANCELED') -> toString (); // canceled date (05.01.2020 21:11:10)
$ order-> getField ('REASON_CANCELED'); // reason for cancellation  

Set the order status "Canceled"

  if (CModule :: IncludeModule ("sale") && CModule :: IncludeModule ("catalog"))
{
$ order_id = $ _POST ['sendData'] ['id'];

$ order = \ Bitrix \ Sale \ Order :: loadByAccountNumber ($ order_id);
$ r = $ order-> setField ('STATUS_ID', 'C');

if (! $ r-> isSuccess ()) {
var_dump ($ r-> getErrorMessages ());
}

$ r = $ order-> save ();

if (! $ r-> isSuccess ()) {
var_dump ($ r-> getErrorMessages ());
} else {
echo {
$ _POST ['sendData'] ['id']
}
}  

Comments

There are no comments yet, you can be the first to leave it

Leave a comment

The site uses a comment pre-moderation system, so your message will be published only after approval by the moderator

You are replying to a user's comment

Send

FEEDBACK

Email me

Are you developing a new service, making improvements to the existing one and want to be better than your competitors? You have come to the right place. I offer you a comprehensive studio-level website development. From me you can order design, layout, programming, development of non-traditional functionality, implementation of communication between CMS, CRM and Data Analitics, as well as everything else related to sites, except for promotion.

Contact, I will always advise on all questions and help you find the most effective solution for your business. I am engaged in the creation of sites in Novosibirsk and in other regions of Russia, I also work with the CIS countries. You will be satisfied with our cooperation

An error occurred while sending, please try again after a while
Message sent successfully

Phones

+7(993) 007-18-96

Email

info@tichiy.ru

Address

Россия, г. Москва

By submitting the form, you automatically confirm that you have read and accept the Privacy Policy site

Contact with me
Send message
By submitting the form, you automatically confirm that you have read and accept Privacy policy of site
Sending successful!
Thank you for contacting :) I will contact you as soon as possible
Sending failed
An error occurred while sending the request. Please wait and try again after a while or call my phone number