替换对象数组中的值

Joh*_*ery 0 php arrays object

我有以下数组:::

WC_Cart Object (
  [cart_contents] => Array (
    [d6f5bb0bbc] => Array (
      [product_id] => 14
      [variation_id] => 325
      [variation] => Array (
        [Your Build] => Windows
      )
      [quantity] => 1
Run Code Online (Sandbox Code Playgroud)

如何更换(更新)[quantity] => 1[quantity] => 3:::

任何援助将不胜感激 :::

更新>>>更多信息.使事情更清楚

下面是我想要访问的钩子(woocommerce_calculate_totals)来改变上面打印的数组中的值,这些值源于print_r($this);:::

我不知道如何创建我需要更新值的函数 add_action( 'woocommerce_calculate_totals', 'my_quantity' );

我曾经使用过数组和钩子,但这有点超出我的联盟:::

//允许插件在计算最终总数之前挂钩并更改总计

do_action('woocommerce_calculate_totals', $this);                   

            /** 
             * Grand Total
             *
             * Based on discounted product prices, discounted tax, shipping cost + tax, and any discounts to be added after tax (e.g. store credit)
             */

$this->total = apply_filters('woocommerce_calculated_total', number_format( $this->cart_contents_total + $this->tax_total + $this->shipping_tax_total + $this->shipping_total - $this->discount_total, 2, '.', ''), $this);
Run Code Online (Sandbox Code Playgroud)

biz*_*lop 7

这是你想要的?

$wc_cart->cart_contents['d6f5bb0bbc']['quantity'] = 3;
Run Code Online (Sandbox Code Playgroud)

访问数组和对象的几个示例:

$object->some_property
$object->{'complex'.'property'.'name'.(2*3)}
$array[12]
$array['hello']
$array[ $array_index*10 ]
Run Code Online (Sandbox Code Playgroud)

了解有关数组和对象的更多信息: