g

Restore Order & Arbitrary Data

Restore Order

Use the Restore Order to repopulate the cart with the order items, only if the order has not been completed or has status of "quote". You can find the Restore Cart URL under Transaction on each Order.

This URL will allow the customer to finish off a previously failed checkout. Once they populate the Cart, two variables are assigned to the cart page:

$restoreOrderSuccess - success message (only populated on complete restore)
$restoreOrderError - error message from restore


Restore Order has two uses:

  • Use on a declined order - it will restore the existing order and allow the customer to update this order.
  • Use on a fully paid order with status "quote" - it should create a duplicate order, and not update the original. 


Arbitrary Data

Arbitrary Data allows the developer to include custom information saved as a JSON string within the Order. This will allow unlimited amount of custom fields if required.

In order to save this data you can do one of the following:

  1. In checkout_shipping or checkout_payment add a hidden field with JSON-encoded string:

<input type="hidden" id="order_json_data" name="order_json_data" value='{"one":"abc","two":["three","four"],"five":5}' />


On complete checkout you can see this saved:

2. In checkout_shipping or checkout_payment, add hidden fields in PHP array notation. The values coming from two customer details from and payment form will be merged in the end

customer_details.html
<input type="hidden" name="order_json_data[Question One]" value="Answer 1">
<input type="hidden" name="order_json_data[Question Two][One]" value="2.1">
<input type="hidden" name="order_json_data[Question Two][Two]" value="2.2">
payment.html
<input type="hidden" name="order_json_data[Question Three]" value="Answer 3">
<input type="hidden" name="order_json_data[Question Two][Three]" value="2.3">

Upon completion of checkout the following information will be displayed in the DXP:

3. You can save it using the Order Object functions:

$order->setJsonData([1=>'one',2=>'two',3=>'three']); // the object function supports both regular arrays or a json_encoded string
$order->update(); // make sure you save your changes!


Finally, to get the data regardless of how you save it: 

$order->getJsonData(); // outputs array
// or use
$order->getArbitraryData();