@@ -24,40 +24,32 @@ class QuantityCollector
2424 */
2525 public function collectItemsQtys (Quote $ quote )
2626 {
27- if (!isset ($ this ->quoteCache [$ quote ->getEntityId ()])) {
28- $ quoteItems = $ quote ->getAllVisibleItems ();
29- $ quote ->setItemsCount (0 );
30- $ quote ->setItemsQty (0 );
31- $ quote ->setVirtualItemsQty (0 );
32-
33- foreach ($ quoteItems as $ item ) {
34- if ($ item ->getParentItem ()) {
35- continue ;
36- }
27+ $ quoteItems = $ quote ->getAllVisibleItems ();
28+ $ quote ->setItemsCount (0 );
29+ $ quote ->setItemsQty (0 );
30+ $ quote ->setVirtualItemsQty (0 );
31+
32+ foreach ($ quoteItems as $ item ) {
33+ if ($ item ->getParentItem ()) {
34+ continue ;
35+ }
3736
38- $ children = $ item ->getChildren ();
39- if ($ children && $ item ->isShipSeparately ()) {
40- foreach ($ children as $ child ) {
41- if ($ child ->getProduct ()->getIsVirtual ()) {
42- $ quote ->setVirtualItemsQty (
43- $ quote ->getVirtualItemsQty () + $ child ->getQty () * $ item ->getQty ()
44- );
45- }
37+ $ children = $ item ->getChildren ();
38+ if ($ children && $ item ->isShipSeparately ()) {
39+ foreach ($ children as $ child ) {
40+ if ($ child ->getProduct ()->getIsVirtual ()) {
41+ $ quote ->setVirtualItemsQty ($ quote ->getVirtualItemsQty () + $ child ->getQty () * $ item ->getQty ());
4642 }
4743 }
48-
49- if ($ item ->getProduct ()->getIsVirtual ()) {
50- $ quote ->setVirtualItemsQty ($ quote ->getVirtualItemsQty () + $ item ->getQty ());
51- }
52- $ quote ->setItemsCount ($ quote ->getItemsCount () + 1 );
53- $ quote ->setItemsQty ((float )$ quote ->getItemsQty () + $ item ->getQty ());
5444 }
5545
56- $ this ->quoteCache [$ quote ->getEntityId ()] = $ quote ;
57-
58- return $ quote ;
46+ if ($ item ->getProduct ()->getIsVirtual ()) {
47+ $ quote ->setVirtualItemsQty ($ quote ->getVirtualItemsQty () + $ item ->getQty ());
48+ }
49+ $ quote ->setItemsCount ($ quote ->getItemsCount () + 1 );
50+ $ quote ->setItemsQty ((float )$ quote ->getItemsQty () + $ item ->getQty ());
5951 }
6052
61- return $ this -> quoteCache [ $ quote-> getEntityId ()] ;
53+ return $ quote ;
6254 }
6355}
0 commit comments