• Resolved fotodino

    (@fotodino)


    Hey there,

    It appears that when I create a product with the api and add this to the meta_data array.

     "meta_data": [
                {
                    "key": "wpru_enable",
                    "value": "1"
                },
                {
                    "key": "wpru_users",
                    "value": [
                        ${steps.create_user_in_woocommerce.$return_value.user.ID}
                    ]
                },
                {
                    "key": "wpru_mode",
                    "value": "view"
                }
            ]

    It does not show up for that specific user.
    ${steps.create_user_in_woocommerce.$return_value.user.ID} gets turned into a value and I confirmed this by going into the product manually. If I then save this product, the product shows for that client.

    Can you suggest a way I can do this with an api instead of having to go into each created product manually and saving them?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter fotodino

    (@fotodino)

    It might not be related to this plugin at all, as the customers can access the URL of that product directly. It just does not show up on the shop page.
    See slack https://woocommercecommunity.slack.com/archives/C1KAZ91E3/p1658396097642749 for further reference.

    Thread Starter fotodino

    (@fotodino)

    Okay, it seems to still be an issue of this plugin.
    Disabling it allows the customer to see the product. (But also all others)
    Is there any way I can trigger the shop display via api or hook?

    Plugin Author Javier Carazo

    (@carazo)

    @fotodino,

    Which solution do you think is better?

    Making this values not to be set by default?

    Thread Starter fotodino

    (@fotodino)

    Dear @carazo,

    Thanks for your quick reply. I appreciate you taking your time to look through my post

    I am not sure I understand your solution.
    My use case is the following:
    I create custom products via the api and want to lock them to the specific customer. I can get their wordpress ID and I set the meta data of the product so that only that customer can access that. Now I expect the customer to be able to see this after they directly login (i.e. shown in their shop page) In reality it does not show, but I rather have to manually go to the editor and press “Update” for the product to appear in the clients store.

    I assume some hook only gets run after pressing “Update”, while it would be good to run it as part of the product creation hook (maybe https://stackoverflow.com/a/72963732 helps here?)

    I hope my Explanation was useful.

    Feel free to ask me further questions, I really enjoy using your plugin.

    Best wishes
    fotodino

    Plugin Author Javier Carazo

    (@carazo)

    @fotodino,

    You can update the metadata we use when you create the product via API.

    This is the best way to solve your problem.

    Thread Starter fotodino

    (@fotodino)

    Hey @carazo,

    I assume you mean using the API to issue a PUT Request and update the product?
    This does not resolve the problem of the product showing up on the shop page.
    Am I correct in assuming that the plugin only sets

     "meta_data": [
                {
                    "key": "wpru_enable",
                    "value": "1"
                },
                {
                    "key": "wpru_users",
                    "value": [
                        42
                    ]
                },
                {
                    "key": "wpru_mode",
                    "value": "view"
                }
            ]

    this metadata?

    If I use this metadata, the user with the ID 42 can access the product via direct link, but it does not appear in his shop page.

    Or what do you mean by “update metadata”?

    Best wishes

    Plugin Author Javier Carazo

    (@carazo)

    No, this is not the idea.

    It would be best if you extended the create product method to get new vars and update this metadata and the one which affects users. wpru_allowed_products for example in user meta.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Support for woocommerce api create products’ is closed to new replies.