/var/www/vhosts/ihelp.ro/httpdocs/src/Controller
Edit: /var/www/vhosts/ihelp.ro/httpdocs/src/Controller/UserAddressesController.php (1482B)
Authentication->addUnauthenticatedActions(['removeAddress']);
}
/**
* removeAddress
*/
public function removeAddress($cartUuid = null)
{
if ($cartUuid) {
//$this->request->allowMethod(['post', 'delete']);
$this->loadModel('Carts');
$cart = $this->Carts->find()
->contain(['UserAddresses'])
->where(['Carts.uuid' => $cartUuid])
->first();
if ($cart) {
if ($this->UserAddresses->delete($cart->user_address)) {
$this->Carts->id = $cart->id;
$this->Carts->saveField('user_address_id', NULL);
$this->Flash->success(__('The user address has been deleted.'));
} else {
$this->Flash->error(__('The user address could not be deleted. Please, try again.'));
}
}
}
return $this->redirect(['prefix' => false, 'controller' => 'Orders', 'action' => 'checkout']);
}
}