@@ 108-136 (lines=29) @@ | ||
105 | * @param Buyable $product [optional] |
|
106 | * @param int $quantity [optional] |
|
107 | */ |
|
108 | public function updateRemoveResponse(&$request, &$response, $product = null, $quantity = 1) |
|
109 | { |
|
110 | if ($request->isAjax()) { |
|
111 | if (!$response) { |
|
112 | $response = $this->owner->getResponse(); |
|
113 | } |
|
114 | $response->removeHeader('Content-Type'); |
|
115 | $response->addHeader('Content-Type', 'application/json; charset=utf-8'); |
|
116 | $shoppingcart = ShoppingCart::curr(); |
|
117 | $shoppingcart->calculate(); // recalculate the shopping cart |
|
118 | ||
119 | $data = array( |
|
120 | 'id' => (string) $product->ID, |
|
121 | 'message' => array( |
|
122 | 'content' => $this->owner->cart->getMessage(), |
|
123 | 'type' => $this->owner->cart->getMessageType(), |
|
124 | ), |
|
125 | ); |
|
126 | $this->owner->cart->clearMessage(); |
|
127 | ||
128 | if ($shoppingcart) { |
|
129 | $data['subTotal'] = $shoppingcart->SubTotal(); |
|
130 | $data['grandTotal'] = $shoppingcart->GrandTotal(); |
|
131 | } |
|
132 | ||
133 | $this->owner->extend('updateRemoveResponseShopJsonResponse', $data, $request, $response, $product, $quantity); |
|
134 | $response->setBody(json_encode($data)); |
|
135 | } |
|
136 | } |
|
137 | ||
138 | /** |
|
139 | * Remove all of an item from a cart (Cart Page) |
|
@@ 147-175 (lines=29) @@ | ||
144 | * @param AjaxHTTPResponse $response |
|
145 | * @param Buyable $product [optional] |
|
146 | */ |
|
147 | public function updateRemoveAllResponse(&$request, &$response, $product = null) |
|
148 | { |
|
149 | if ($request->isAjax()) { |
|
150 | if (!$response) { |
|
151 | $response = $this->owner->getResponse(); |
|
152 | } |
|
153 | $response->removeHeader('Content-Type'); |
|
154 | $response->addHeader('Content-Type', 'application/json; charset=utf-8'); |
|
155 | $shoppingcart = ShoppingCart::curr(); |
|
156 | $shoppingcart->calculate(); // recalculate the shopping cart |
|
157 | ||
158 | $data = array( |
|
159 | 'id' => (string) $product->ID, |
|
160 | 'message' => array( |
|
161 | 'content' => $this->owner->cart->getMessage(), |
|
162 | 'type' => $this->owner->cart->getMessageType(), |
|
163 | ), |
|
164 | ); |
|
165 | $this->owner->cart->clearMessage(); |
|
166 | ||
167 | if ($shoppingcart) { |
|
168 | $data['subTotal'] = $shoppingcart->SubTotal(); |
|
169 | $data['grandTotal'] = $shoppingcart->GrandTotal(); |
|
170 | } |
|
171 | ||
172 | $this->owner->extend('updateRemoveAllResponseShopJsonResponse', $data, $request, $response, $product); |
|
173 | $response->setBody(json_encode($data)); |
|
174 | } |
|
175 | } |
|
176 | ||
177 | /** |
|
178 | * Update the quantity of an item in a cart (Cart Page) |