Mail: [email protected] Phone: +1(424)231-4091

Procurement: Prefill Products

The product prefill is a feature added from NexoPOS 5.3.3. this allows to create a list of product that will be populated while creating a procurement. This feature might be used to suggest procurement to the end user.

How Does It Work?

To make it work, you need to use the class "ProcurementService" which now provides new methods: "storePreload" and "preload". The "storePreload" method accepts 4 parameters:

  • hash: it's a unique string generated to identify the products. You might use Str::uuid().
  • items: it's either an array of a collection with the following entries (product_id, unit_id, quantity)
  • multiplier: used to multiply how many times the items are added to the procurement list. The default value is 1.
  • expiration: define after how many times (in seconds) the prefill will expire and be cleared.

Load The Prefilled Products

You need to redirect to the procurement page with an extra query argument (preload). When the query argument "preload" has as value the $uniqueId we created, the product will be fetched and added to the table.

Here is what the URL must look like.

yourwebsite.com/dashboard/procurement/create?preload=48927940-f2af-4d0e-83e1-d43b493989ef

Note that you can use the helper "ns()->route( 'ns.procurement-create' )" to get the procurement URL.