WooCommerce Order meta data appears twice, once with underscore - php

I have inherited a site built on Woo-Commerce that I'm helping out a non-profit with. It has a few problems that I've been fixing, but seeing some odd bugs when they edit the orders.
It seems like all the order billing meta data tags appear twice, once with underscore and once without, like:
_billing_first_name
billing_first_name
They both contain the value enter by the customer when they made the order, however the underscore version is what gets edited if you use the Admin dashboard to edit the billing info, and the NON underscore version appears under custom fields.
This is causing some confusion, and I have done a fair bit of searching and not figured out the why.
Thanks in advance if anybody has any hints, otherwise I'll be poking into the code.

This is completely normal (and is not a bug).
As woocommerce is a Wordpress plugin, it use the classic User data tables. But Orders are a custom post type that store they own user data.
In woocommerce as you can buy optionally without being registered, in that case the user data is only located on the Order postmeta data.
When non registered user make his first purchase (registering at the same time) the data is saved in both wp_usermeta and wp_postmeta tables.
When user register before purchasing anything, the data will be registered only in wp_usermeta table.
For all of that reasons there is 2 locations for user data:
1) billing_first_name - The user data is stored on wp_usermeta table and it's editable from the user my account pages (or on backend from users edit pages).
2) _billing_first_name (start always with an underscore) - The order customer data stored in wp_postmeta table and it's only editable through backend Order edit pages by admins and shop managers. This data is displayed on orders everywhere and on email notifications...
The underscore at the beginning is avoid this data to be displayed in custom fields Meta BOX (in Order edit pages).
So an Order can have different billing or shipping fields than in usermeta data, as a customer can have different billing/shipping data if he want to.
Woocommerce needs both of them. You should not make any change related to this, because it will be a real nightmare for you…

Related

Randomly assign woocommerce orders from a specific category to store managers

I've searched everywhere for a solution to this but can't seem to find something that matches my exact scenario.
Here's my scenario;
When an order from a "specific category" named "Typing Service" is placed, I want it randomly assigned to a staff (store manager) with a custom role named "Typist"
The typist (store manager) is able to handle and update the order status. Typist can only see and handle orders that has been assigned to him.
The site admin should have an option on the orders page to reassign the order to a different Typist in an event where the previously randomly assigned typist is not available to handle the order.
I was able to find a code that does part 2. of my problem on this link.
But I can't figure out how he implemented part 1. which is critical for part 2. to work. I would really appreciate any help, preferably a code I can add via code snippets plugin or to functions.php.
I'm using How can I assign an order to a certain shop manager in Woocommerce
But how do I make it assign the order randomly instead to any store manager with a custom role "Typist"

Wordpress asigning product to user to show report

Wordpress, Advanced Custom Fields (ACF), Woocommerce
Hello,
currently I am working on project that is needed to manage products (Music artists) and customers (bars/lounges).
I need to solve the communication between "artist(product) being booked/purchased as product by bar/lounge(customer)" in Woocommerce.
Artists must be able to login and see if they have been booked by customer and the additional information must be shown (who is the customer (bar or lounge name), place, when, how long, must take his equipment or not).
I am thinking of asigning product id(artist) to user role - artist.
User login is generated manualy by administrator.
Artist logins by the credentials given by administrator and is able to see his own report of the information that must be shown.
Advanced custom fields custom user role and post type as woocommerce product
Is there any possiblity lets say for the purchase that is finished to be displayed not only for administrator but for user "Artist".
I am thinking of editing wp-admin/profile.php , but is it the correct way of doing it?
I will try updating the solution where I have gone so far, as soon as there will be new information.
You can add artists as vendor's, and with same name product. Now assign that product to that vendor. Whenever his product is bought he will get notification and can see stats also. As he can log in to dashboard with some restricted access. Many vendor plugins are there in market. I am giving you a sample one :
https://wordpress.org/plugins/yith-woocommerce-product-vendors/

How to make Woocommerce not to save Checkout billing fields

I have a particular case where I need many people to login to ONE specially created user (one login name and one password for all) and purchase items through it. The problem is if Person A logins with this ONE user credentials and makes a purchase he will leave a trace in shipping/billing details, person B will then see those details when in checkout page. Woocommerce saves those details by default, how could I disable that? How can I make Woocommerce Chechout page to always have empty fields with no prepopulated data from previous purchases?
Thanks!
Mantas
you need this filter... this filter is meant to overwrite the values being displayed at checkout... below will return empty string... to empty the values being displayed.
add_filter('woocommerce_checkout_get_value','__return_empty_string',10);
But this does not mean, these values won't be seen in other places.. like "My Account" page..

Silverstripe Handler

I am trying to find ways to do a piece of functionality which is nice to have. Not sure how to approach. Proper silverstripe way would be good.
I have a website (built in Silverstripe)that has multiple types of products, example
Payment type (Products that needs payment)
Email type (Products that does not need payment but just requires users email)
Just delivery type (Products that does not need payment but need users address)
The idea is, users can add anytype of product to the basket and basket summary shows all the different types of products the user has added to basket. Once the user clicks checkout button , each type of product has its own handler to do the checkout.
How can i achieve this? Ideas please i.e how should I structure/architect it.
Ideally I would like to have this URL structure
http://example.com/orders/checkout/Payment
http://example.com/orders/checkout/Email
http://example.com/orders/checkout/Delivery
R
I'd recommend that you start with an existing SilverStripe e-commerce module.
https://github.com/silvershop/silvershop-core
http://www.silvercart.org/
https://github.com/sunnysideup/silverstripe-ecommerce
SilverShop is my personal preference.

Add custom attributes like serial number to order_item and quote_item

I want to add a custom attribute to magento order_item and quote_item and a field in the order form for my serial number attribute and other custom attributes.
I'm selling Tablets offline but I am using Magento backend for managing all inventory and customer information along with orders, the tablets are given on subscription bases so there is no shipping as the customer would be at store during purchase.
I want to add custom attribute which are unique to the customer and tablet.
I could create an attribute for the customer but what if they order more than one tablets which means logically the only way is to place those attributes in the order item.
I seriously don't know how to go about.
I hope someone can point me to extended magento sales module and add my custom attribute to order_item and also show in magento order form.
First you need to add/change this two tables:
- sales_flat_order_item
- sales_flat_quote_item
just add fields and name it as you wish (that will be your new attributes)
file you need to edit for your new attribute to be visible on order page should be this one:
app/design/adminhtml/default/default/template/sales/order/view/items/renderer/default.phtml
and your new attribute:
<?php echo $_item->getMyCustomAttribute() ?>
If you would like to make that attribute "the proper way" it requires a bit more skill..
Here is an example how you can add custom category attribute, same would be for your problem:
http://inchoo.net/ecommerce/magento/how-to-add-new-custom-category-attribute-in-magento/
Thanks
I would ask some of the more popular extension providers for a custom quote. AheadWorks comes to my mind quickly... I say visit the Magento Connect store and browse through highly rated extensions and you'll see there are a small number of companies doing lots of successful work.
They will be able to "more properly" handle, store, track, and communicate your desired data through the entire system.
Once I better quantify a similar situation I would like to program, I will seek the help of experienced module builders. The Zend MVC is a miserable bowl of spaghetti once you start trying to code in it! :D

Categories