WPCloud Deploy Documentation

WooCommerce & WPCloudDeploy Servers

Introduction

WPCloudDeploy makes it easy to offer your customers the opportunity to purchase WordPress cloud servers using WooCommerce.  However, in order to use this feature you need to pull together a bunch of moving parts.  And, relative to what you might expect in the WordPress world, the components you need are not cheap.

When completely set up, this integration will allow your customers to purchase one of three sized servers from any of your server providers.  It will provide a way to list their servers on the front-end of the site and then manage them on the back-end. (This integration does not offer server management capabilities on the front-end).

Customers will be able to pay with Stripe or Paypal.  Other payment methods might work but they are not officially supported.

Pre-requisites

Plugins

Here are the items you need to make this happen (in addition to WPCloudDeploy)

Fix WooCommerce Default Login Action

You will need a method to bypass WooCommerce’s default account page on login.  WooCommerce tends to hijack the WordPress login process and send most users to the WC account area.  But we want them to be able to go to our servers page instead.  You can override the WC default behavior using one of the following options:

  • Turn on the option we have specifically for this under SETTINGS->APP:WORDPRESS SETTINGS->WooCommerce Options.  This affects ALL WooCommerce users.  If that’s not the behavior you want you’ll need to use one of the other options below.
  • Custom code
  • Giving your users a higher level default role (not recommended)

Roles and Capabilities for WooCommerce Customers

Finally, you will need to grant the SUBSCRIBER roles the following CAPABILITIES so that they can see the WPCloudDeploy menu option in wp-admin:

  • wpcd_manage_servers
  • wpcd_manage_apps

The SUBSCRIBER role is the default role that WooCommerce assigns to users who have made a subscription purchase.  If, for some reason, a different role is set for the user after a purchase (such as CUSTOMER) then you should add these capabilities to that role.

You can control which roles are assigned to a user after purchase on the WOOCOMMERCE->SUBSCRIPTIONS tab.

Setup Server Sizes

Because each cloud server provider have so many different options for server sizes, the first thing you need to do is decide which sizes you will offer.  To keep things simple we have created THREE default sizes that we call “Small”, “Medium” and “Large”.  Your customers will then be able to choose one of these three sizes.

To setup these three sizes, go to WPCloudDeploy->Settings->Cloud Providers.

There, at the bottom of each of the cloud providers tabs you can map “small”, “medium” and “large” to one of the server offerings from the provider.

If you need additional sizes, you can create your own complete custom set on the WPCLOUDDEPLOY->SETTINGS->FIELDS tab – just scroll to the bottom where  you’ll see the option to setup your own server sizes.

Setup WooCommerce Products

After server sizes have been set up, you can start to create WooCommerce Products.

To create a product:

  • Navigate to Products->Add New
  • Fill in a product name and description as you would usually do with a WooCommerce product
  • Enable the Virtual checkbox
  • For the product type, choose Simple Subscription.  This will cause a new tab to show up labeled WordPress Server
  • Click on the WordPress Server tab and enable the first checkbox with the label This is a WordPress server
  • Select the server size from the server size drop-down.
  • Click on the General tab to set up your subscription prices.
  • Click on the Inventory tab to enable stock management – turn on the option for Sold Individually.
  • Finally, click on the PUBLISH button.

Remove Ajax Buttons

If you’ll be using the WC product archive pages, you must remove the AJAX buttons because they bypass the product detail page.  The product detail page is where the customer choose their server options.

One way to disable these buttons is via CSS such as the following (your theme might have slightly different classes):

.archive .add_to_cart_button {
display: none; !important
}

Customer Checkout Flow

When a customer views a WordPress server product, they will be allowed to select their provider (if you have more than one) as well as the location (region) where the server should be deployed.

 

After checkout is complete, a receipt is shown with an informational message at the top of the screen – this message is blank by default but you can customize it in the WPCLOUDDEPLOY SETTINGS screen (See the THANK YOU page section below for more information about this option.)

In the image below, the area in red is completely customized.


The THANK YOU Page Notice

In the image above we highlighted the customized notice that can be added to the WooCommerce thank-you page.  The thank-you page is the page the user sees at the very end of the WC checkout process and is a standard part of all WC checkout flows.

It is important to create your own notice – by default we leave this notice blank.  But if you do not create a custom notice, the user will not get a link to the page where they can view and manage their servers.

You can configure this notice as follows:

  • Go to WPCLOUDDEPLOY->SETTINGS->APP:WORDPRESS-SETTINGS->SELL WP SERVERS.
  • Scroll down to the THANK YOU PAGE section
  • Add your text and then click the SAVE SETTINGS button.

You’re probably asking what you should use as the text in there.  The answer depends on where you want to send the user after the checkout is complete.  You have two options:

  1. Send them to a page with the shortcode that is on the front end (see the SHORT CODE section below).  From there they can click a button to get to wp-admin to manage their servers or
  2. Send them directly to the wp-admin backend (https://yourdomain.come/wp-admin)

Once you’ve made your decision you add text that contains the appropriate link.

Short Code

In order for users to be able to see their list of servers on the front-end, you need to add a short-code to a page and then provide a link to that page in one of your menus (or some other location on your site).

The short-code to use is:

wpcd_app_wpapp_wc_servers

Note: Prior to WPCD Versions 4.6, the shortcode was wpcd_app_wpapp_instances

It is not strictly necessary to setup a page with this short-code since all server management will be taking place inside wp-admin anyway.  But it is a nice option.  The short-code will render a screen that looks like this on the front-end:

 


Important Notes

Server Cancellations

When a subscription is cancelled, the server is automatically deleted.  Generally, if the user cancels prior to the end of the subscription period, the subscription will go into a “pending cancellation” status.  The server will then be deleted at the end of the period when the subscription switches to “cancelled” status..  But the admin can force immediate deletion by forcing the subscription status to Cancelled.

Basically the rule is this – if the status in the WooCommerce SUBSCRIPTIONS list is “Cancelled” the server is going to be deleted or has been deleted.

This is important because it means that your customer can lose all their server data if they do not renew their subscription or if the subscription is allowed to enter “Cancelled” status for any reason.  There is NO grace period!

Backups With S3

When selling server subscriptions, how you configure your S3 backup credentials become very important.  Please see the bottom of our backup documentation page for more information.


Other Configuration Options

There are a number of optional configuration items that can be used to help promote sales or inform the user of next steps after the sale is completed.  You can find these options under the WPCLOUD DEPLOY->SETTINGS->APP:WORDPRESS SETTINGS tab.  There, you’ll see sub-tabs related to WooCommerce.  In these tabs you can:

  • Configure links to products that encourage the user to purchase additional servers – these links show up in the front-end on the server list screen (see the short-code section above).
  • Configure links to products that encourage the user to purchase a server if their server list on the front-end is blank.
  • Configure text that goes at the top of the receipt screen at the end of the checkout process (see the THANK YOU section above).

 

In the above image you might notice a weird token in the THANK YOU PAGE TEXT box – ##WORDPRESSAPPWCSERVERSACCOUNTPAGE##.  This is a substitute for the data in the URL TO ACCOUNT PAGE and ACCOUNT PAGE LINK TEXT – it combines the two to make a nice link for you.  The use of this token is completely optional and you can choose to just place text with the link directly in the THANK YOU PAGE TEXT box.

Checkout Limitations

Because the user needs to specify certain custom items (such as provider and region) before an item is added to a cart, any links that do direct add-to-cart will not work.  The user will be able to checkout and setup a subscription but no server will be provisioned for the order.

The user MUST go through the product detail screen to add a WordPress server product to the cart.

Thus, you will likely want to modify your default WooCommerce display to remove any links or buttons that take the user directly from the product display to the cart.  If you only plan on selling a limited number of server-provider-size configurations, you might consider not using the default WooCommerce shop page and create a custom page with product links instead.

Additionally, in order to prevent abuse, you should definitely set an inventory limit for each product.  Otherwise, someone can try checkout with 50,000 servers in their cart! How do we know this?  Because someone actually tried to do it on one of our sites!

Finally, you might want to make sure that only ONE server can be purchased at a time.  You can enable this when setting up the product – Click on the Inventory tab to enable stock management and turn on the option for Sold Individually.

WP Cron Requirements

WP CRON needs to be fired on a regular basis.  Otherwise, emails will not be sent when a server is provisioned.  WPCD should have WP CRON set to fire every minute anyway so if you already have that configured, then this requirement should not be an issue.

Other Comments

When a server is purchased, a WordPress site is NOT added to the server.  Instead, the user still needs to be in wp-admin in order to add sites to a server.

Other Considerations

There might be certain tabs on a server screen that you do not want your customers to access.  You can disable them in wp-config.php.  Learn more under the WPCD_SERVER_HIDE_TABS_WHEN_AUTHOR section in this help document.


Customer Contributions

A customer created and used the following PHP code to change the function of the AJAX button:

add_filter( ‘woocommerce_loop_add_to_cart_link’, ‘replace_add_to_cart_button’, 10, 2 );
function replace_add_to_cart_button( $button, $product ) {
     if (is_product_category() || is_shop()) {
          $button_text = __(“Select Region”, “woocommerce”);
          $button_link = $product->get_permalink();
          $button = ‘<a class=”button” href=”‘ . $product->get_permalink() . ‘”>’ . $button_text . ‘</a>’;
          return $button;
     }
}

Note: No support is provided for customer contributions – we’re providing these in case you find them useful.


 

Share: