Search
 
SCRIPT & CODE EXAMPLE
 

PHP

how to search by sku woocommerce

function get_product_by_sku( $sku ) {
  global $wpdb;

  $product_id = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key='_sku' AND meta_value='%s' LIMIT 1", $sku ) );

  if ( $product_id ) return new WC_Product( $product_id );

  return null;
}
Comment

PREVIOUS NEXT
Code Example
Php :: drupal 7 hook_form_alter 
Php :: 18 year back date in php 
Php :: LARAVEL CREAT NEW TEST 
Php :: php constant array 
Php :: php mysqli fetch single row 
Php :: Str laravel 9 
Php :: laravel ckeditor 
Php :: first name of string php 
Php :: get ip country 
Php :: get month first date and last date in php 
Php :: add days to date in php 
Php :: image storage storepublicy in laravel 
Php :: disable laravel passport 
Php :: how to set date in php 
Php :: redirect woocommerce thank you 
Php :: Pass all data to all pages laravel 
Php :: Laravel 5.4 Route back in blade 
Php :: remove all sessions in laravel 
Php :: set unique value validation for laravel form request 
Php :: laravel deleted controller still cached 
Php :: clear laravel.log 
Php :: php exec without waiting 
Php :: php not recognized 
Php :: laravel store method 
Php :: xamp to test on mobile 
Php :: how get query logs in laravel 
Php :: laravel findorfail 
Php :: string remove last two characters php 
Php :: laravel blade empty 
Php :: get where different laravel 
ADD CONTENT
Topic
Content
Source link
Name
4+5 =