Allow for cloning the cart object

This handles creating new instances of the `$session` and `$fees_api` properties.
This commit is contained in:
Jeremy Pry 2017-11-03 15:50:43 -04:00
parent 0cca83ff83
commit 9eee3805c0
1 changed files with 9 additions and 0 deletions

View File

@ -122,6 +122,15 @@ class WC_Cart extends WC_Legacy_Cart {
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.