Unique User Role Report WooCommerce - wordpress

Two questions involved in my quagmire:
Where do I find 'report functionality' in the woo themes plugins?
How do I implement reporting for a custom user role in the orders section (the custom user role has already been created in WP?
Example:
sales by date | sales by product | sales by 'custom user role here'

Solution for Query 1:
The report functionality can be assessed from front-end via WooCommerce->Reports as shown in the following image
The backend of this functionality comes from the Package WooCommerce/Admin/Reports i.e. within the file structure of
/woocommerce/includes/admin/reports/
Solution for Query 2:
WooCommerce doesn't provide "sales by 'custom user role here'" by deafult but you can code so or you can use Woocommerce Order Report Snapshot plugin to get roles specific reports

Related

how I can let shop manger read and write only one field in woo commerce

I am trying to let shop manger access (read & write) only one field on order detail dishoard.
How I can disable other field?
There is a function in wordpress which manage to select very detailed permissions: https://pl.wordpress.org/plugins/user-role-editor/
There is Plan B, I call it Jewish Method: There is a function in wordpress get_role( string $role ). You can edit function when these fields are being rendered for individual roles

How to Sync CPT Data oder BG Group Meta with User/member

i have big Challenge and i want to know, if it’s possible.
I need a Solution to create Company Profiles with Fields about the Adress, ZipCode, City etc… This Company can create a user (employee).
This User can invite another User(employee) to this Company.
If he do that, the Company profile Fields must be Synced with the Employee Profile Field Data.
The Employee Fild Data about the Company must be the Same as tthe Company.
My Acutally Setup:
User Creation: BuddyPress
Company Profiles: With BuddyPress Groups
To create a Group (Company) and a User Registration i use Buddyforms.
Buddyforms Create a new Post in a Custom Post Type with the Company Information an attach this Post to the Group.
Maybe is it possible, all BP Group Members will be synced with this custom fields?
Or maybe i need another Solution?
Regards

WooCommerce filter out records if it's created/updated by a specified user-id

I want to GET Products from WooCommerce based on URL - https://example.com/wp-json/wc/v3/products?modified_after=2022-03-07T23:04:00Z
However, I want to exclude records from the GET Response if it's updated by a specific system user-ID (integrationuser#example.com).
Is there any way to achieve this in WooCommerce using REST API or programmatically by some scripting language?

Is it possible to pass a special query parameter value to a WooCommerce product link?

I am looking to use WooCommerce in a bit of a strange way, and I'm wondering if there is any way to make this possible. Here's my desired workflow:
Step #1: From a different site subdomain, provide a link to a certain virtual product, but with a query parameter with a unique user id number.
Explanation: The user is at othersite.example.com, and they get a link to buy a product in a WooCommerce store set up with a wordpress site at https://example.com/product/virtual-product
However, this product will be a payment to unlock something on the othersite.example.com site which has its own user and authentication system. (Firebase)
Would it be possible to pass a user id from the othersite.example.com by way of a url query parameter and then have that included in the order info?
ie. From the othersite.example.com someone could be given a link to the product like this https://example.com/product/virtual-product?userid=00000000000000000, with 00000000000000000 being their user id at othersite.example.com.
Then if that userid query value could be included in the order, the following steps should be doable.
Step #2: Have a webhook that fires when the product is purchased, telling a server managing the users for othersite.example.com that the user with userid 00000000000000000 has made a successful purchase of that product.
Is there a way to accept custom values like this to the order? Or is this totally out of the scope of WooCommerce's functionality?
Thanks so much.
I believe that it can be done by using a redirection/link directly to the checkout page, like: "http://yourdomain.com/checkout/?add-to-cart=PRODUCTID&000000" (tested)
In the example, "checkout" stands for the name of your checkout page, "PRODUCTID" stands for the id of desired product, "000000" stands for the user id of redirected person in the other website.
Then you can add a hidden input field to the checkout page (into checkout form, so you will see this value in order) and using the URL you can assign the "000000" (user id) to the value of this field.
I hope that works. If you have any problems with implementation, you can ask me.
- Useful link for hidden input field addition: https://stackoverflow.com/a/42614905/11003615
- Useful link for getting value from current URL using JS: https://web-design-weekly.com/snippets/get-url-with-javascript/
- Useful link for getting value from current URL using PHP/Wordpress Core: https://wordpress.stackexchange.com/questions/274569/how-to-get-url-of-current-page-displayed
- Useful link (contains 4 parts) for adding a custom field to checkout & validating this field & saving this field to order fields & displaying the value of this field in order page: https://docs.woocommerce.com/document/tutorial-customising-checkout-fields-using-actions-and-filters/#section-7

Wordpress - Add a user as custom field of CPT

Intro info:
I have a Custom Post Type (CPT) called Service.
I am already connecting users to this CPT using the plug-in 'Posts 2 Posts', this is a many to many relation, and these users connected to the CPT represent the 'team' of said Service.
Alright so here's the headscratcher:
Now I want to create a custom field in the CPT Service, which will be the Director of the Service. Say a field called 'Director' in which the value is a User.
Ideally, the value of the field Director is a User, not a string representing the user name or anything like that.
I have no idea how to start tackling this issue and some brightness on the subject would be strongly appreciated.
Thank you!
save it as post_meta. e.g if you have the user email:
$user = get_user_by( 'email');
update_post_meta($serviceid, '_director', $user->ID);
If you are setting this up in the admin section you can add a meta box and attach a action to save_posts to save a html field where you select a user. Google add_meta_box, there are a load of tutorials on this.

Resources