• Resolved snyne

    (@snyne)


    I use WooCommerce memberships / subscriptions and at the end of each month I want to credit all active members with access to a product, but only if they are signed up for that month. Similar to how Playstation Plus works.

    Is there any plugin or addon that I can use for that?

    Cheers

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support EastOfWest a11n

    (@eastofwest)

    Hi there,

    AutomateWoo can help you achieve this. If you have more specific questions about it, please do ask them via the this form.

    Plugin Support abwaita a11n

    (@abwaita)

    Hi @snyne,

    We’ve not heard back from you in a while, so I’m marking this thread as resolved. Hopefully, the above suggestion was helpful!

    If you have further questions, please feel free to open a new topic.

    Thanks.

    Thread Starter snyne

    (@snyne)

    Hey there, this isn’t resolved but it will be after I answer.

    Firstly, you need to get a list of userids from the email, this can be done directly via SQL, unfortunately the WooCommerce API is hot trash and if someone is a SUBSCRIBER role (rather than a customer role — por que no los dos?) it will not return as a customer at the /customers?email=… endpoint. But if you have Raw SQL access you can do:

    SELECT user_id FROM wp_wc_customer_lookup where email IN ( ... );

    Where the … is a comma seperated list of all the email addresses that you wish to resolve. You want the USER_ID and not the customer_id for giving out products (man, I wish I knew that first…)

    From there you need to generate a coupon for 100% off customer purchases under marketing->coupons and then you can use the product delimited to select specific ones.

    After doing that you can hit the API endpoint directly with the minimum amount of JSON necessary, which looks something like this

    HTTP POST <domain>/wp-json/wc/v3/orders/:
    {
      "customer_id":CUSTOMER_ID_HERE,
      "set_paid": true,
      "coupon_lines": [
            {
                "code": "COUPON_CODE_HERE"
            }
      ],
      "line_items": [
        {
          "product_id": PRODUCT_ID_HERE,
          "quantity": 1
        }
      ]
    }
    

    And this will resolve the issue for you, for free, without needing to buy AutomateWoo

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Is there a way to GIVE someone a virtual product’ is closed to new replies.