display wp_postmeta meta_value in wordpress woocommerce - php

please help a new member
THE ISSUE:
I have a POS on my WC and it doesn't display sequential orders numbering, so I am using other plugin to achieve this. I need to display the value of a meta_value from my database in the order receipt (printable ticket) after the order is placed. So, the meta_value I need to display on the POS's tickets is the sequential ticket number created by the other plugin.
Gladly this other plugin creates the sequential number in the database from where I hope I can retrieve it somehow.
This meta_value for example "T00001...T00009" has the meta_key = "_order_number" and it's within wp5o_postmeta table of my sql database.
I believe it must be easy for you guys...
Thank you so much
Image of the data

use this filter and implement your post meta
wordpress/wp-content/plugins/woocommerce-openpos/includes/front/Front.php
line 4683
$result['data'] = apply_filters('op_get_next_order_number_info',$order_number_info);

Related

Update/insert meta_key and meta_value in wp_postmeta

I have a website with coupons and a large database. In wp_postmeta most of my posts have a store_id, because I use the plugin Yoast SEO and it sets the meta_key and the meta_value. Not all of my coupons have a store_id in the wp_postmeta, like the older coupons or some of them who was copied from the old ones, or who came automatically through API.
If I update every coupon and re-click the store part, the post gets the store_id written in the table wp_postmeta. But I have more than 50 000 coupons... I need the store_id set for every coupon I have, for other tasks I need to do.
Is there an easier way how to do this, without manually updating every coupon?
First, please make a backup.
If I understand correctly, yoiu need to change every row in the wp_postmeta table to set the store_id to the same value. If I've misunderstood in some way, that is, if you need to set a different value for some rows or if you don't want to over-write existing data, you should stop reading here. I don't know anything about Yoast SEO and only know as much as I've perceived from your post here.
But changing a single column for all rows is easy. You need an SQL statement something like this:
UPDATE `wp_postmeta` SET `store_id`=1
That will change the store_id of every row in wp_postmeta to 1.
Since you've tagged phpMyAdmin, presumably you're using that as your interface. Just click the SQL tab once you're in your WordPress database to enter the text of the query directly there.

Count meta_keys (Wordpress)

Is there a simple way to count how often a meta_key exists in the database like wordpress do with:
$n_post = wp_count_posts();
Anybody can help?
Check last rows in a table which are associated with specific user/post, Take that ID and count meta_keys on the bases of that ID, Hope it will return all the meta_keys...

OpenCart : Extract Orders Details in Database

I know I can extract Sales Order data in OpenCart database, in table shop_order and shop_order_product.
Is it possible to differentiate which user creates the sales order?
I don't think there's an option to identify which admin user created the order. You may need to code it yourself. The below steps may help you.
Add 2 new fields created_user_id and updated_user_id in order table - with default value as 0.
Update the admin/model/sale/order.php to insert values to those fields as $this->user->getId(); (addOrder and editOrder functions ).
Add a new field user_id in order_history table - with default value as 0.
Update the admin/model/sale/order.php to insert value to that field as $this->user->getId(); (function: addOrderHistory).
You can do these by directly modifying the files or using vqmod. If it's done via vqmod then it'll be easier for you to make changes during opencart version upgrade.
Opencart: Vqmod tutorial
Have a nice day!!
By default, there's no way to know which admin an order is created by, or even that the order isn't created by the user (other than the IP would be that of the admin). You could in theory add the user_id to the shop_order table, and pass that to the manual order editor when it creates the orders

Selecting most recent result from MySQL where there are more than 1 rows matching ID

I'm using wordpress with some custom fields, to cut this short, im echoing out all rows that have the meta_key of post_author that arent empty and grouping likewise names together otherwise i might get Pete, Steve, Pete - when all i need is Pete, Steve. Below is the SQL that makes that work
$wpAuthors = $wpdb->get_results($wpdb->prepare("SELECT DISTINCT(meta_value)
FROM $wpdb->postmeta WHERE meta_value !='' AND meta_key = 'post_author'
ORDER BY meta_key ASC"));
That works great. But what if i change the author FROM pete TO steve? Of course wordpress makes a duplicate entry for that post id, with a different Custom field row id. (Post ID on both rows would be something like 1100 while entry rows might be 3000 and 3001). Now the issue here is that my script still works, because both Pete and Steve are entered into the database in the correct column, but what i need it to do now is to select the most recent copy of that post id row to get the most recent author, does that make sense? I hope so!
define('WP_POST_REVISIONS', false); Add this variable in to wp-config.php, it will prevent wordpress to create post revisions.
After that install this plugin http://wordpress.org/plugins/wp-optimize/screenshots/.
Now remove all post revisions using above wp-optimize plugin.

get magento order id from customer data

I'm having problems getting a collection with join working. I'm trying to get the order ID's connected to customer telephone numbers, saved in sales_flat_order_address. So a join on the collection with sales/order and a filter based on the variable with my phone number in it. I've tried all sorts of combinations, but so far I only get errors and right now I've deleted my code and will try from scratch. Any ideas or links to tutorials about this?
Small code snippet below
$customer = Mage::getModel('customer/customer')->getCollection()
->addAttributeToFilter('attribute_code', value)->load();
//Here your attribute code is phone
$orderCollection = Mage::getModel(’sales/order’)->getCollection();
$orderCollection->getSelect()->where(’e.customer_id =’.$customer->getId());
:)

Categories