We had a support thread handled by Luo Yang that was marked resolved, but now I'm seeing that was premature. There is still an issue with the Billing Company field you helped us add.
Here is the original support thread:
https://toolset.com/forums/topic/woocommerce-billing-company-field/
Here is one view where this field was added:
hidden link
Here is the page where that view is displayed:
hidden link
You entered "test billing company" into my user account and it was displaying the correct results before. But since then I did another test order and included Three Sages Productions as my company name. That worked as expected it replaced "test billing company" with Three Sages Productions on all my test orders. I expected it to do that since the field in my user account changed.
Note the problem here is that the company name Three Sages Productions is appearing on all the orders. It should only be on the ones made by Kenneth Moore. I'm not sure how/why Three Sages Productions is also showing on the order by Kelly Boutwell. She does not have a user account on the site and did not include a company name on her order as far as I know. The code you set up seemingly pulled from my user account and applied it to Kelly's test order.
Kelly will be doing another test order shortly because I changed our Woocommerce settings to force account creation on orders. I told her to make sure to fill out the Company Name field when she does her next test order too. So I *think* or at least hope her Company Name should display properly once she does that. Can you tell if something needs to be changed with the code to prevent Three Sages Productions from displaying incorrectly on her current test order?
Hello,
The website credentials you provided in previous thread was removed for protecting your privacy.
Please share your website credentials in below private message box, I need to test and debug it in a live website. thanks
I can login into your website, I assume we are talking about the this order post:
hidden link
It is created by a guest(not a member), he/she does not have user profile, and does not have "billing_company" custom user field.
In this case, it is stored as a custom post field in Woocommerce order post, the field slug is "_billing_company", so you can display it directly, for example:
1) Edit the order post:
hidden link
For test purpose, edit the Billing company field as: Test billing company
2) edit the post view "Manage Members", in section "Loop item in Manage Members", line 6, display it with shortcode:
[wpv-post-field name="_billing_company"]
Test it in frontend:
hidden link
It works fine, can you confirm it?
Yes, you have the correct test order.
I do see where you edited the Billing Company field within the order.
I also see where that order is now displaying "test billing company" on the report page.
But if you look at the first order in the list from january 3, you'll see that the billing company field is errantly displaying the company name twice. And the problem order we're looking at here is now displaying "Three Sages ProductionsTest billing company" instead of just Test billing company. So something still isn't right with how this is set up. I don't know where the Kelly Boutwell order is getting Three Sages Productions from. It shouldn't as that company name has only been used on the January 3rd test order I created. I understand why my other two previous test orders pull that company name from my user profile, but I have no idea how or why Kelly's test order would do that. Can we change how you've coded this to pull the company name from that field in the order rather than using the user data?
For those Woocommerce order placed by logged user, you can use below codes to output billing company field value:
[wpv-conditional if="([wpv-post-field name="_customer_user"] eq 0)" evaluate="false"][wpv-user field='billing_company' id='[wpv-post-field name="_customer_user"]'][/wpv-conditional]
For guest user(none-logged-in), you can use below codes to output billing company field value:
[wpv-conditional if="([wpv-post-field name="_customer_user"] eq 0)" evaluate="true"][wpv-post-field name="_billing_company"][/wpv-conditional]
See the codes in below post view, section "Loop item in Manage Members"
hidden link
line 7~8
See the result here:
hidden link
Just to make sure I correctly understand how you've set this up, you're conditionally checking if the order was placed by a user with an account. If it was, then you're using the company name associated with the user account. If it was placed by a user without an account, you're using the company name associated with the order. Is that correct?
The results are now displaying as we want them to. I'll have to watch this when we start getting real orders in to make sure customers don't find a way to make this not work as intended. But it's displaying what it should be displaying on all orders right now, so it's good.
Thanks a bunch again!
Yes, you are right, it needs to check if the order was placed by a user with an account.
OK, great! Thanks for the help again.
That's likely all we need for this website, but I have two more clients with sites heavily dependent on Drupal Views that I'm going to migrate to WordPress next. They'll definitely be purchasing your plugin.
I'll mark this one as resolved.
My issue is resolved now. Thank you!