Skip to content

Instantly share code, notes, and snippets.

@hscstudio
Created January 17, 2016 23:44
Show Gist options
  • Save hscstudio/de15ef4e2c20bbc11677 to your computer and use it in GitHub Desktop.
Save hscstudio/de15ef4e2c20bbc11677 to your computer and use it in GitHub Desktop.
public function sync(Cart $cart) {
$this->storages[0]->read($cart);
$last_cart = clone $cart;
$this->storages[0]->lock(true, $cart);
$cart = $last_cart;
$this->storages[1]->read($cart);
$this->storages[1]->write($cart);
/*$this->storages[1]->read($cart);
$current_cart = clone $cart;
$this->storages[0]->read($cart);
$this->storages[0]->lock(true, $cart);
echo "<h1>Item Storage 2</h1>";
var_dump($current_cart->items);
echo "<hr>";
echo "<h1>Item Storage 1</h1>";
var_dump($cart->items);
//
$cart->items = array_merge($current_cart->items, $cart->items);
echo "<hr>";
echo "<h1>Item After Array Merge</h1>";
var_dump($cart->items);
$this->storages[1]->write($cart);
*/
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment