Skip to content

Commit

Permalink
Fix for API cart delete with GET method
Browse files Browse the repository at this point in the history
  • Loading branch information
abantecart committed Mar 10, 2016
1 parent 7d85a51 commit ed80758
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions public_html/storefront/controller/api/checkout/cart.php
Expand Up @@ -55,9 +55,11 @@ public function post() {
}

//request to remove
if (isset($request['remove'])) {
if (isset($request['remove']) && is_array($request['remove']) ) {
foreach (array_keys($request['remove']) as $key) {
$this->cart->remove($key);
if($key) {
$this->cart->remove($key);
}
}
}

Expand Down Expand Up @@ -128,13 +130,20 @@ public function post() {
public function delete() {
$request = $this->rest->getRequestParams();

if (isset($request['remove'])) {
$count = 0;
if (isset($request['remove']) && is_array($request['remove'])) {
foreach (array_keys($request['remove']) as $key) {
$this->cart->remove($key);
if($key) {
$this->cart->remove($key);
$count++;
}
}
}
}

$this->rest->setResponseData( array('success' => "$count removed" ) );
$this->rest->sendResponse(200);
return null;
}

public function put() {

Expand Down

0 comments on commit ed80758

Please sign in to comment.