cart, $this->customer, $this->location, $this->shipping_methods, $this->payment_method, $this->currency, $this->is_recurring_cart, $extras, $this->data ); } /** * Copy with a data entry. * * @param string $key Key. * @param mixed $value Value. */ public function with_data( string $key, mixed $value ): self { $data = $this->data; $data[ $key ] = $value; return new self( $this->cart, $this->customer, $this->location, $this->shipping_methods, $this->payment_method, $this->currency, $this->is_recurring_cart, $this->offered_extras, $data ); } /** * Copy with another location. * * @param string $location Location. */ public function with_location( string $location ): self { return new self( $this->cart, $this->customer, $location, $this->shipping_methods, $this->payment_method, $this->currency, $this->is_recurring_cart, $this->offered_extras, $this->data ); } /** * Reads a data entry. * * @param string $key Key. * @param mixed $fallback Value when missing. * @return mixed */ public function get( string $key, mixed $fallback = null ): mixed { return array_key_exists( $key, $this->data ) ? $this->data[ $key ] : $fallback; } /** * Subtotal as displayed to the customer (same base WooCommerce uses for free shipping). */ public function subtotal(): float { return $this->cart ? (float) $this->cart->get_displayed_subtotal() : 0.0; } }