Jump to content

Botón Vaciar Carrito


vive

Recommended Posts

Hola!

 

¿Habría alguna forma de insertar un botón para vaciar el carrito por completo, tubiera uno o varios artículos?

 

La idea es que si posteriormente a pulsar ese botón se añade algo al carrito, sea ya otro identificador diferente de carrito.

 

Muchas gracias.

Link to comment
Share on other sites

  • 2 weeks later...
  • 1 month later...

en el shopping-cart.tpl

 

line 82

 

<th class="cart_delete last_item"><a href="{$link->getPageLink('cart', true, NULL, "emptyCart=1&token={$token_cart}")}" title="{l s='Delete'}">{l s='Eliminar todo'}</a></th>

 

en la clase CartController.php

 

//line 67

if (Tools::getIsset('add') || Tools::getIsset('update'))

{

$this->processChangeProductInCart();

}

else if (Tools::getIsset('emptyCart'))

{

$this->emptyCart();

}

 

 

//final .php

protected function emptyCart()

{

 

$result = array();

$result['summary'] = $this->context->cart->getSummaryDetails(null, true);

foreach ($result['summary']['products'] as $key => &$product)

{

$this->processDeleteProduct($product['id_product'],$product['id_product_attribute'],$product['customization_id'],$product['id_address_delivery']);

}

 

 

}

 

 

protected function processDeleteProduct($idProd, $idAttrib, $custom_id, $id_address)

{

if ($this->context->cart->deleteProduct($idProd, $idAttrib, $custom_id, $id_address))

{

if (!Cart::getNbProducts((int)($this->context->cart->id)))

{

$this->context->cart->setDeliveryOption(null);

$this->context->cart->gift = 0;

$this->context->cart->gift_message = '';

$this->context->cart->update();

}

}

$removed = CartRule::autoAddToCart();

if (count($removed) && (int)Tools::getValue('allow_refresh'))

$this->ajax_refresh = true;

}

Link to comment
Share on other sites

en el shopping-cart.tpl

 

line 82

 

<th class="cart_delete last_item"><a href="{$link->getPageLink('cart', true, NULL, "emptyCart=1&token={$token_cart}")}" title="{l s='Delete'}">{l s='Eliminar todo'}</a></th>

 

en la clase CartController.php

 

//line 67

if (Tools::getIsset('add') || Tools::getIsset('update'))

{

$this->processChangeProductInCart();

}

else if (Tools::getIsset('emptyCart'))

{

$this->emptyCart();

}

 

 

//final .php

protected function emptyCart()

{

 

$result = array();

$result['summary'] = $this->context->cart->getSummaryDetails(null, true);

foreach ($result['summary']['products'] as $key => &$product)

{

$this->processDeleteProduct($product['id_product'],$product['id_product_attribute'],$product['customization_id'],$product['id_address_delivery']);

}

 

 

}

 

 

protected function processDeleteProduct($idProd, $idAttrib, $custom_id, $id_address)

{

if ($this->context->cart->deleteProduct($idProd, $idAttrib, $custom_id, $id_address))

{

if (!Cart::getNbProducts((int)($this->context->cart->id)))

{

$this->context->cart->setDeliveryOption(null);

$this->context->cart->gift = 0;

$this->context->cart->gift_message = '';

$this->context->cart->update();

}

}

$removed = CartRule::autoAddToCart();

if (count($removed) && (int)Tools::getValue('allow_refresh'))

$this->ajax_refresh = true;

}

 

¿Seguro?

Link to comment
Share on other sites

  • 4 weeks later...

Buenas tardes,

 

Este código dónde se pone exactamente?

 

//final .php

protected function emptyCart()

{

 

$result = array();

$result['summary'] = $this->context->cart->getSummaryDetails(null, true);

foreach ($result['summary']['products'] as $key => &$product)

{

$this->processDeleteProduct($product['id_product'],$product['id_product_attribute'],$product['customization_id'],$product['id_address_delivery']);

}

 

 

}

 

 

protected function processDeleteProduct($idProd, $idAttrib, $custom_id, $id_address)

{

if ($this->context->cart->deleteProduct($idProd, $idAttrib, $custom_id, $id_address))

{

if (!Cart::getNbProducts((int)($this->context->cart->id)))

{

$this->context->cart->setDeliveryOption(null);

$this->context->cart->gift = 0;

$this->context->cart->gift_message = '';

$this->context->cart->update();

}

}

$removed = CartRule::autoAddToCart();

if (count($removed) && (int)Tools::getValue('allow_refresh'))

$this->ajax_refresh = true;

}

 

Sabéis si funciona en las versiones 1.4.x?

 

Muchas gracias compañeros.

Link to comment
Share on other sites

en el shopping-cart.tpl

 

line 82

 

<th class="cart_delete last_item"><a href="{$link->getPageLink('cart', true, NULL, "emptyCart=1&token={$token_cart}")}" title="{l s='Delete'}">{l s='Eliminar todo'}</a></th>

 

en la clase CartController.php

 

//line 67

if (Tools::getIsset('add') || Tools::getIsset('update'))

{

$this->processChangeProductInCart();

}

else if (Tools::getIsset('emptyCart'))

{

$this->emptyCart();

}

 

 

//final .php

protected function emptyCart()

{

 

$result = array();

$result['summary'] = $this->context->cart->getSummaryDetails(null, true);

foreach ($result['summary']['products'] as $key => &$product)

{

$this->processDeleteProduct($product['id_product'],$product['id_product_attribute'],$product['customization_id'],$product['id_address_delivery']);

}

 

 

}

 

 

protected function processDeleteProduct($idProd, $idAttrib, $custom_id, $id_address)

{

if ($this->context->cart->deleteProduct($idProd, $idAttrib, $custom_id, $id_address))

{

if (!Cart::getNbProducts((int)($this->context->cart->id)))

{

$this->context->cart->setDeliveryOption(null);

$this->context->cart->gift = 0;

$this->context->cart->gift_message = '';

$this->context->cart->update();

}

}

$removed = CartRule::autoAddToCart();

if (count($removed) && (int)Tools::getValue('allow_refresh'))

$this->ajax_refresh = true;

}

 

Gracias, me ha funcionado.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...