Public Ticket #3663998

Creating a rule with REST API

Closed
Comments
2,762
KingsPlugins replied 2 years ago on June 10, 2024 at 7:19pm

Hello Lasse,

The issue seems to be the REST API authentication, as you get a 401 - unauthorized error. Therefore I think the issue is not the code, but the general authentication (getting the site to understand you have the right to create rules).


Previously in our tests, it helped to install this REST API authentication plugin: https://wordpress.org/plugins/wp-rest-api-authentication/ - it may be needed to try a few methods in order to find one that works for your setup.


Kind regards,

Stefan


14 Tickets 2
Lasse replied 2 years ago on June 11, 2024 at 7:58am

What worked. Now for a different problem. When exporting product and user data, we have to use, the predefined parameters in wordpress fx the first user is user_1 the second is user_2. This makes it incredible hard to target, as we have a unik parameter (Debitor number) and to that, we want to target the product by sku number, but it's the same story here. 


Is there some way, to define that the product is selected based on sku number?

2,762
KingsPlugins replied 2 years ago on June 13, 2024 at 9:46pm

Regarding that, I don't see a simple way of making rules work directly with SKU or other user data I'm afraid. I looked at whether we can add some kind of snippet or code, but it seems code changes would be needed in dozens of places including internal caches for which rules apply to which users.

It may be easier to run calls to get the product ID from the SKU first.



Another possibility I'd like to mention:

I noticed that in your rule example below you are setting a specific price for a specific product and user. We are currently working on a new feature for user-based price lists, and as part of that it is now already possible to set this kind of pricing directly by modifying post / product meta data.

Specifically, for each product you can set:

- 'b2bking_regular_price_user_'.$user_id

- 'b2bking_sale_price_user_'.$user_id

OR

- 'b2bking_regular_price_user_'.$username

- 'b2bking_sale_price_user_'.$username


So for example to set the price of a product for the user admin as 50, you can create a product meta entry for that product, setting the meta key 'b2bking_regular_price_user_admin' to the value 50.


Sign In