GithubHelp home page GithubHelp logo

isabella232 / woocommerce-subscriptions-restrict-product Goto Github PK

View Code? Open in Web Editor NEW

This project forked from woocommerce/woocommerce-subscriptions-restrict-product

0.0 0.0 0.0 487 KB

Restricts subscription products to a certain number of total active (unended) subscriptions on a site.

License: GNU General Public License v3.0

PHP 100.00%

woocommerce-subscriptions-restrict-product's Introduction

WooCommerce Subscriptions Restrict Product

Restricts subscription products to a certain number of total active (unended) subscriptions on a site.

Use case: store owner wants products and subscriptions to have a one-to-one relationship, i.e. each product should only be subscribed to once. For example, subscription product is a child to be sponsored, and only one subscriber should be sponsoring that child at a time.

This plugin creates and maintains a list of products that have unended subscriptions associated with them, then makes these products unpurchasable from front end to make sure that the subscription product can only be subscribed to a certain number of times. It doesn't change ability to check out with product, so that customer can pay for failed order through cart, and manual renewals are unaffected.

Note: This plugin is designed to work independently of the WooCommerce inventory system, and so inventory should be disabled for all subscription products, or you may have problems with customers not being able to pay for failed renewal orders manually.

Installation

To install:

  1. Download the latest version of the plugin here
  2. Go to Plugins > Add New > Upload administration screen on your WordPress site
  3. Select the ZIP file you just downloaded
  4. Click Install Now
  5. Click Activate

How-to

Set Product Restriction

There are two ways to set a product restriction, either storewide or on a product level. Setting a product level restriction is more specific and will override the storewide default. If you set either to '0' or leave them empty, they are considered not set.

Storewide Restriction

You can set a default storewide restriction which will apply to all subscription products by going to WooCommerce -> settings -> Subscriptions (tab) -> Product Restriction

Admin settings

Product-level Restriction

You can also set a product restriction for a specific product by editing the product, and clicking on the 'Advanced Options' tab in the Product Data metabox. This will set the product restriction on a product level for simple and variable subscription products. That means that the restriction applies no matter which variation of a variable product is subscribed to.

  • To activate the product-level restriction, you must click the "Activate product-level restriction" checkbox.
  • If "Activate product-level restriction" checkbox is checked, but the restriction quantity is blank, then no restriction will be applied to this product, even if there is a systemwide default set elsewhere.

Product settings

Renewals and Switching

Renewals and Switches are taken into account when checking if a purchase should be restricted.

Renewals

Automatic renewals are not restricted at all, and should process normally. Similarly, manual renewals will still allow the product to be purchased/renewed through the cart.

Subscription Switching

Switching is accounted for when checking restrictions. When switching between simple subscription products, the checks still occur as normal. When switching between variations of the same product, the restrictions are ignored, allowing the switch to occur.

Visibility

When displaying a product in the catalog or archive pages, this plugin will hide the product if it is restricted, and if the 'Out of stock visibility' option is checked in WooCommerce settings -> products -> inventory tab.

Warning Messages

There is currently no way to customize the warning message presented when a restriction is encountered. Additionally, when product variations are deemed not purchasable, the default WooCommerce alert box is triggered, which is not descriptive of why.

For this reason, we recommend you add in some descriptive text to your product description indicating that it is restricted, and why.

Additional Notes

  • Restrictions don't apply retroactively, only to future purchases. In other words, any given purchase is checked against the current restriction and current number of active site-wide subscriptions. No already-existing subscriptions will be cancelled or suspended if you change the restriction number. Future purchases will be checked against subscriptions that existed before the plugin was activated, however.
  • Deactivating the plugin will stop the restriction checks, and will delete the cache. However, the restriction option values (set in the WooCommerce settings tab or product options) will stay in place in case you choose to reactivate the plugin in the future.

Troubleshooting

To view the current cache for troubleshooting purposes, navigate to the 'plugins' page and click the 'view cache' option. View cache

Updates

To keep the plugin up-to-date, use the GitHub Updater.

Reporting Issues

If you find a problem or would like to request this plugin be extended, please open a new Issue.

woocommerce-subscriptions-restrict-product's People

Contributors

lcmry avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.