Saturday, November 5, 2022
HomeWordPress Developmentphp - Get woocommerce worth of a product provides unusual error

php – Get woocommerce worth of a product provides unusual error


I get the merchandise like this:

 $args = array(
    'class' => array("all the things" ),
    'orderby'  => 'title',
  );
  $merchandise = wc_get_products( $args );
  print_r($merchandise); // I see all of the merchandise.. title, description, worth, regular_price..

right here print_r($merchandise[0]);

WC_Product_Simple Object
(
    [object_type:protected] => product
    [post_type:protected] => product
    [cache_group:protected] => merchandise
    [data:protected] => Array
        (
            [name] => My Rattling Product
            [slug] => goddamnItWhereIsYourFCKINGprice?
            [date_created] => WC_DateTime Object
                (
                    [utc_offset:protected] => 0
                    [date] => 2022-10-29 22:00:11.000000
                    [timezone_type] => 1
                    [timezone] => +00:00
                )

            [date_modified] => WC_DateTime Object
                (
                    [utc_offset:protected] => 0
                    [date] => 2022-10-29 22:04:13.000000
                    [timezone_type] => 1
                    [timezone] => +00:00
                )

            [status] => publish
            [featured] => 
            [catalog_visibility] => seen
            [description] => 
            [short_description] => 
            [sku] => 
            [price] => 22
            [regular_price] => 22
           //... 

now I wish to get the title of the primary product:

  print($merchandise[0]->title); // provides "My Rattling Product Title"

now I wish to get the worth of the primary product:

  print($merchandise[0]->worth);  //NOW all the things explodes..

Deadly error: Uncaught Error: Name to undefined operate
wc_empty_cart() in C:UsersuserLocal
SitesSiteapppublicwp-contentpluginswoocommerceincludesclass-wc-session-handler.php
on line 372 ( ! ) Error: Name to undefined operate wc_empty_cart() in
C:UsersuserLocal
SitesSiteapppublicwp-contentpluginswoocommerceincludesclass-wc-session-handler.php
on line 372

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments