Skip to content

poconosewandvac/Commerce_GuestOrder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Commerce_GuestOrder

Lets guest customer's easily view their previous orders. Uses the frontend/account/order-detail.twig file in your Commerce theme. Requires Modmore's Commerce to use https://www.modmore.com/commerce/

Usage

After downloading and installing the transport package, create a Guest Order resource and call the snipped uncached.

[[!GetGuestOrder]]

This will use the included chunks "GetGuestOrderForm" for the formTpl option and "GetGuestOrderError" for the errorTpl option.

Options

Validation Fields

By default, the snippet validates against the zip field in comAddress, however it can validate against any column in comAddress or even multiple fields. For example, if you wanted to validate the zip and email field you would call GetGuestOrder with the fields property (where each field is comma seperated)

[[!GetGuestOrder? &fields=`zip, email`]]

This would also require a change to your formTpl to input the new field, which can be any chunk you create (formTpl). You will need to add the fields using the name attribute name="values[column]". For example, a sample form for using zip and email could be

<form action="[[~[[*id]]]]" method="POST">
    <input type="text" name="order" placeholder="Order ID" />
    <input type="text" placeholder="Zip Code" name="values[zip]" />
    <input type="text" placeholder="Email" name="values[email]" />
    <button type="submit">Submit</button>
</form>

Secret

Inside comOrder, there is a column, secret, that can be alternatively be used to access the order. This is useful for linking a "Track my order" button inside a status change. For example, inside "order-received.twig" you could have (where RESOURCEID is the page you have the GetGuestOrder snippet on)

{% if order.user == 0 %}
    <a href="[[~RESOURCEID? &scheme=`full`]]?order={{ order.reference|url_encode }}&secret={{ order.secret|url_encode }}">Track your order</a>
{% else %}
    <!-- Something could be put here for registered users to login to their account to track their order -->
{% endif %}

If you do not want this feature, you can disable it using the snippet option useSecret and set it to 0.

Address Type

This option defines which address to verify the fields against. It can be either shipping, billing, or both (default).

Allow Registered Users

Kind of defeats the "Guest" in the name of this module, but you can let registered users quickly view their orders without signing in by setting the allowRegistered snippet property to 1. It is disabled by default.

Template

Below are the template settings you can override.

  • tpl: template to use for order view (twig)
  • formTpl: template to use for the form (chunk)
  • errorTpl: template to use when order could not be verified or found (chunk)

Since this extra is heavily based on the commerce.get_order snippet included with commerce, you can also use the properties loadItems, loadStatus, loadTransactions, loadBillingAddress, loadShippingAddress, and loadShipments. All default to 1, set to 0 to disable. See more information about these properties on the modmore documentation https://docs.modmore.com/en/Commerce/v1/Snippets/get_order.html

Use ID Fallback

Commerce 0.12 introduced a new field on orders, reference, which prevents orders that haven't been completed from counting towards the order count. By default, guest order will first check for an order reference, then look for an order by ID if the useIdFallback snippet property is enabled (enabled by default for older shop compatability).

On new shops, this can be safely disabled because all templates reference the order reference.