Search
 
SCRIPT & CODE EXAMPLE
 

PHP

obtener datos de orden wordpress php

// Get an instance of the WC_Order object
$order = wc_get_order($order_id);

// Iterating through each WC_Order_Item_Product objects
foreach ($order->get_items() as $item_key => $item_values):

    ## Using WC_Order_Item methods ##

    // Item ID is directly accessible from the $item_key in the foreach loop or
    $item_id = $item_values->get_id();

    ## Using WC_Order_Item_Product methods ##

    $item_name = $item_values->get_name(); // Name of the product
    $item_type = $item_values->get_type(); // Type of the order item ("line_item")

    $product_id = $item_values->get_product_id(); // the Product id
    $product = $item_values->get_product(); // the WC_Product object

    ## Access Order Items data properties (in an array of values) ##
    $item_data = $item_values->get_data();

    $product_name = $item_data['name'];
    $product_id = $item_data['product_id'];
    $variation_id = $item_data['variation_id'];
    $quantity = $item_data['quantity'];
    $tax_class = $item_data['tax_class'];
    $line_subtotal = $item_data['subtotal'];
    $line_subtotal_tax = $item_data['subtotal_tax'];
    $line_total = $item_data['total'];
    $line_total_tax = $item_data['total_tax'];

    // Get data from The WC_product object using methods (examples)
    $product_type   = $product->get_type();
    $product_sku    = $product->get_sku();
    $product_price  = $product->get_price();
    $stock_quantity = $product->get_stock_quantity();

endforeach;
Comment

PREVIOUS NEXT
Code Example
Php :: webiste url filter with pregx 
Php :: automatically make created_by and updated_by using observer laravel 
Php :: gan_sql 
Php :: laravel project in css 
Php :: Remove values from select list based on condition 
Php :: how to read laravel query string with dash 
Php :: How to download file with laravel 
Php :: sha256 encode php 
Php :: php define() 
Php :: default password when you make users in laravel 
Php :: phpImage 
Php :: getname eloquent slug laravel 
Php :: recaptcha v3 laravel 8 
Php :: how we show full name of month in posts 
Php :: php calculate age as float 
Php :: PHP $argv echo with number of words 
Php :: PHP how to skip file upload if file already exist 
Php :: php refresh_ttl 
Php :: show all tags 
Php :: php laravel convert blob type to string 
Php :: php artisan tinker new record 
Php :: laravel blade dynamic class loop foreach 
Php :: in php einen div 
Php :: stripe cb test 
Php :: php raw array without foreach 
Php :: php send POST request same folder 
Php :: comment_info 
Php :: Insert Data using modal 
Php :: laravel child relation get max value 
Php :: function wp_maintenance_mode() { 763 
ADD CONTENT
Topic
Content
Source link
Name
4+9 =