Subscription as a Variation

Here’s some code to allow for a regular product and a subscription product on the same page (chosen by variation). Here’s the basic idea for a delivery service that has different services: weekly, biweekly, or just once:

  • Edit the individual product template (source found at foxyshop/themefiles/foxyshop-single-product.php) and put this code into the file, starting on around line 182. Just make sure it goes in before your form ends:
  • Put that edited template file in your theme folder
  • Create a dropdown variation called “Delivery Frequency” and add values called ”Weekly”, “Every Two Weeks”, and “Once”
  • You can change the field name and the wording, but you’ll need to update the javascript to search for your new wording.

If you just want your users to be able to choose between different types (like 1m, 2m, or 3m) use this code:

Posted in: Helpful Code Snippets