Shortcode: Enable Customers to Create A New Scheduled Order

Want to add a simple button to your site that enables customers to create new Scheduled Orders?

In this article, we'll walk through adding this simple shortcode  [autoship-create-scheduled-order-action] to your site as a way to enable your customers to create new Scheduled Orders from the "My Account" page.

'Create Scheduled Order' Shortcode

This shortcode can be used to output a link/button which, when selected, will create a new Scheduled Order for the user based on the supplied attributes. The following attributes are available for the shortcode:

[autoship-create-scheduled-order-action]

  • 'customer_id'
    • The user to create the scheduled order for.
  • 'wrap_start'
    • Append html to beginning ( i.e. an open div )
  • 'wrap_end'
    • Append html to the end ( i.e. a closed div )
  • 'classes'
    • Classes to attach to the link ( classes should be separated by a space )
  • 'products'
    • A list of product ids and associated qty that should be added to the order by default.
    • Ids and Qty should be separated by a : (i.e. 244:2 = Product ID 244 Qty 2 ). 
    • Multiple Products should be separated by a comma
  • 'schedule'
    • The Frequency & Frequency Type separated by a : ( i.e. Months:2 = Every 2 Months )
  • 'next'
    • The Next Occurrence Date in an ISO ISO 8601 date format (i.e. yyyy-mm-dd  like '2022-01-15')
    • A time may be optionally added with a space between Date & Time (so long as it is within the site processing window) and can be in a 12hr. or 24hr. format (eg. '2022-01-15 1:15PM' or '2022-01-15 13:15')
  • 'mincycle'
    • A single min cycle or array of product ids and min cycles to use Ids and Min Cycles should be separated by a : (i.e. 244:2 = Product ID 244 Min Cyle 2 ). 
    • Multiple products should be separated by a comma
  • 'maxcycle'
    • A single max cycle or array of product ids and max cycles to use Ids and Max Cycles should be separated by a : (i.e. 244:2 = Product ID 244 Max Cycle 2 ). 
    • Multiple Products should be separated by a comma
  • 'atts'
    • Any additional data attributes to attach to the link
  • 'label'
    • The label displayed for the Button

Need to Remove the Create Scheduled Order Button?

See our doc My Account: Remove Scheduled Order Creation Button

Example 1: Display Button in My Account > Scheduled Orders

One example of using this shortcode in My Account, is placing it in the "Scheduled Orders Header Message" (  WP-Admin > Autoship Cloud > Settings >> Options tab). This will allow customers to create a new Scheduled Order directly from their My Account page.

Native UI / Hosted iframe

Result: A New Scheduled Order is Created

Once a customer selects the "Create New Scheduled Order" button (enabled by the shortcode), they will be able to edit & configure their new Scheduled Order, setting a Frequency, Next Occurrence Date, and adding Products, Quantities, etc.

Native UI: Create New Scheduled Order Result

Hosted iframe: Create New Scheduled Order Result

Embedded App: Create New Scheduled Order Result

Example 2: Create Scheduled Order w/ Special Attributes

Another example of using this shortcode is to create a unique Scheduled Order that draws the customers' eye. Below we use classes and the "label" attribute to adjust our button display and leverage the shortcode attributes to create a custom Scheduled Order.

Button Created via Shortcode: "Schedule Brake Maintenance"

In this example, a button is created that scheduled all the items a customer may need for brake maintenance with one click! The above shortcode has the following attributes:

  • Class addition to turn the button red
  • Products and their corresponding quantities
  • A Frequency of every 6 Months
  • Maximum cycles of 2 for Product Id 9786 (the other products will not have a cycle limit)
  • Text for to display on the button: "Schedule Brake Maintenance"
  • Setting the recurring price for Product Id: 9810 to $95 (the other products will default to their Autoship Recurring Price)
  • Setting the Next Occurrence Date 

Result: A New Scheduled Order is Created with Custom Attributes:

Once a customer selects the "Schedule Brake Maintenance" button (enabled by the shortcode), they will be able to edit & configure their new Scheduled Order.