Comments (3)
Wenn du auf der zweiten Seite erneut nur die factory() aufrufst, generierst du eine neue Warenkorbinstanz. Du musst die cartId als ersten Parameter übergeben.
Seite 1:
$cart = ShoppingCart::factory();
$cartId = $cart->getId();
Seite 2:
$cart = ShoppingCart::factory($cartId);
Die $cartId musst du dir dann in einer Session oder so speichern, damit du auf der nächsten Seite darauf zugreifen kannst.
Oder aber du gehst gleich von Anfang an folgenden Weg:
Seite 1:
$cart = ShoppingCart::factory('meineTolleId');
Seite 2:
$cart = ShoppingCart::factory('meineTolleId');
from shoppingcart.
Edit: ich hab meinen Code vergessen gehabt:
https://github.com/FriendsOfREDAXO/shoppingcart/blob/master/lib/ShoppingCart.php#L20
Eigentlich müsste dein Ansatz funktionieren, ggf. hast du Cookies nicht erlaubt?
from shoppingcart.
leider funktioniert es nicht..
meine cookies/session wird gespeichert
ich lasse mir die cart per print anzeigen
und die session
seite 1:
CartCart Object([id:CartCart:private] => a0dtq9li85bhuo9lk8gma3ho02[items:CartCart:private] => Array([0] => ShoppingCartItem Object([data:CartCartItem:private] => Array ([quantity] => 1 [price] => 1200 [tax] => 200[name] => Macbook Pro[sku] => MBP8GB[options] => Array([ram] => 8 GB[ssd] => 256 GB)))[1] => ShoppingCartItem Object([data:CartCartItem:private] => Array([quantity] => 1[price] => 959.99[tax] => 200[name] => Macbook Pro[sku] => MBP8GB[meinkey] => is cool)))[store:CartCart:private] => CartStorageSessionStore Object())
seite 2:
CartCart Object([id:CartCart:private] => a0dtq9li85bhuo9lk8gma3ho02[items:CartCart:private] => Array()[store:CartCart:private] => CartStorageSessionStore Object())
session:
Array([a0dtq9li85bhuo9lk8gma3ho02] => a:2:{s:2:"id";s:26:"a0dtq9li85bhuo9lk8gma3ho02";s:5:"items";a:2:{i:0;a:2:{s:2:"id";s:40:"acfe0d7f617feb88676fc5119f6dec4d6be6b93a";s:4:"data";a:6:{s:8:"quantity";i:1;s:5:"price";d:1200;s:3:"tax";d:200;s:4:"name";s:11:"Macbook Pro";s:3:"sku";s:6:"MBP8GB";s:7:"options";a:2:{s:3:"ram";s:4:"8 GB";s:3:"ssd";s:6:"256 GB";}}}i:1;a:2:{s:2:"id";s:40:"c09aef8e5a5f765a4577f4594e4ae1b1490f4639";s:4:"data";a:6:{s:8:"quantity";i:1;s:5:"price";d:959.99000000000001;s:3:"tax";d:200;s:4:"name";s:11:"Macbook Pro";s:3:"sku";s:6:"MBP8GB";s:7:"meinkey";s:7:"is cool";}}}}[cartid] => a0dtq9li85bhuo9lk8gma3ho02)
es sieht so aus als ob alles in der session gespeichert wird aber dan nicht mehr mit deiner addon ausgelesen wird..
ich habe es jetzt mit $cart->restore();
probiert und es funktioniert..
allerdings kommt es zu einer fehlermeldung wenn ich gleich auf seite 2 gehe (also die session ohne inhalt ist)..
from shoppingcart.
Related Issues (6)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from shoppingcart.