我需要一些帮助。我正在尝试获取apply_coupons 公共类的值,但我一辈子都无法在apply_coupons 的公共类中显示数组的值。我根本不是 OOP 世界的大师,我真的迷路了。
转储:
var_dump($woocommerce);
object(Woocommerce)[357]
public 'version' => string '2.0.14' (length=6)
public 'plugin_url' => string 'url here' (length=57)
public 'plugin_path' => string 'path here' (length=52)
public 'template_url' => string 'template here' (length=12)
public 'errors' =>
array
empty
public 'messages' =>
array
empty
public 'query' =>
object(WC_Query)[266]
public 'unfiltered_product_ids' =>
array
empty
public 'filtered_product_ids' =>
array
empty
public 'post__in' =>
array
empty
public 'meta_query' => string '' (length=0)
public 'layered_nav_post__in' =>
array
empty
public 'layered_nav_product_ids' =>
array
empty`enter code here`
public 'product_factory' =>
object(WC_Product_Factory)[254]
public 'cart' =>
object(WC_Cart)[263]
public 'cart_contents' =>
array
'35f4a8d465e6e1edc05f3d8ab658c551' =>
array
...
public 'applied_coupons' =>
array
0 => string 'free249' (length=7)
我需要的:
Applied_coupons 类的值 (free249)
我试过的:
(Returns Null)
$coupon_code_found = $woocommerce->applied_coupons[0];
var_dump($coupon_code_found);
(Returns boolean false)
$coupon_code_found = $woocommerce->applied_coupons;
var_dump($coupon_code_found);
(Returns Null)
$coupon_code_found = $woocommerce->$cart->$WC_Cart->applied_coupons[0];
var_dump($coupon_code_found);