Allow for cloning the cart object
This handles creating new instances of the `$session` and `$fees_api` properties.
This commit is contained in:
parent
0cca83ff83
commit
9eee3805c0
|
@ -122,6 +122,15 @@ class WC_Cart extends WC_Legacy_Cart {
|
||||||
add_action( 'woocommerce_after_checkout_validation', array( $this, 'check_customer_coupons' ), 1 );
|
add_action( 'woocommerce_after_checkout_validation', array( $this, 'check_customer_coupons' ), 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When cloning, ensure object properties are handled.
|
||||||
|
*/
|
||||||
|
public function __clone() {
|
||||||
|
// These properties store a reference to the cart, so just use new instead of clone.
|
||||||
|
$this->session = new WC_Cart_Session( $this );
|
||||||
|
$this->fees_api = new WC_Cart_Fees( $this );
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Getters.
|
| Getters.
|
||||||
|
|
Loading…
Reference in New Issue