Jump to content

Descuento por cantidad de varios productos


ArtByFritsch

Recommended Posts

Revisa en la pestaña Catalogo -> Descuentos -> Reglas del Carrito. En las condiciones creo recordar que podías restringir el cupón a categorías, productos, atributos, etc...

También  tienes dentro de Catalogo -> Descuentos -> La pestaña Reglas de precios de catalogo, para descuentos general al catalogo que vienen a ser los descuentos que tu puedes crear de forma individual en los productos pero de forma masiva (para todos los productos).

http://victor-rodenas.com/crear-descuentos-en-prestashop-1-7/

-----------

El tema de los precios específicos (reglas de precios (no confundir con reglas del carrito o cupones) por categoría, creo recordar que tenias módulo gratuito como la reseña de este: http://victor-rodenas.com/2012/03/20/resena-modulo-para-realizar-descuentos-masivos-por-categorias-en-prestashop/ (Creo que la web de descarga no funciona ya, pero conservo una versión que funcionaba en Prestashop 1.6)

Hablo a nivel Gratuito, porque de pago tienes de todo en la tienda de modulos de prestashop addons.prestashop.com

Saludos,

Edito y actualizo mensaje

Tambien tienes este modulo de shacker: https://www.prestashop.com/forums/topic/121053-modulemass-price-update-v21-ps-1216/ pero creo recordar que trabaja sobre el precio final no como descuento. (Es gratis tambien)

Edited by nadie (see edit history)
  • Like 1
Link to comment
Share on other sites

  • 1 year later...

hola! yo he encontrado este modulo que funciona para 1.6, en teoría, se llama category quantity discount, lo desgargas, lo instalas y al darle a configurar sale esto:

The line below will appear in RED until you copy the modified file, it will turn GREEN after you copy the file and reload the page.

 

Copy /module/categoryquantitydiscount/modified_1.6.1/override/classes/Product.php      hasta      /override/classes/

 

If you already have Product.php in /override/classes/ you will need to copy or merge the "getPriceStatic()" function from our modified file.

 

No queda muy claro que hay que hacer... dentro de la carpeta module/categoryquantitydiscount/modified_1.6.1/override/classes ya está el archivo product.php

por lo que no sé a donde lo tengo que copiar, ya que no encuentro ninguna otra carpeta en todo el https que se llame override

Como dice que si ya lo tienes tienes que copiar la función "getpricestatic" ¿pero a donde hay que copiarla?

¿Alguien puede ayudar?

Mil gracias

 

category quantity.jpg

Link to comment
Share on other sites

Te envío el archivo que aparece en module/categoryquantitydiscount/modified_1.6.1/override/classes/Product.php

<?php
/*
* 2007-2012 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
*  @author PrestaShop SA <[email protected]>
*  @copyright  2007-2012 PrestaShop SA
*  @version  Release: $Revision: 14944 $
*  @license   http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*/

class Product extends ProductCore
{
    /**
    * Get product price
    *
    * @param integer $id_product Product id
    * @param boolean $usetax With taxes or not (optional)
    * @param integer $id_product_attribute Product attribute id (optional). If set to false, do not apply the combination price impact. NULL does apply the default combination price impact.
    * @param integer $decimals Number of decimals (optional)
    * @param integer $divisor Useful when paying many time without fees (optional)
    * @param boolean $only_reduc Returns only the reduction amount
    * @param boolean $usereduc Set if the returned amount will include reduction
    * @param integer $quantity Required for quantity discount application (default value: 1)
    * @param boolean $forceAssociatedTax DEPRECATED - NOT USED Force to apply the associated tax. Only works when the parameter $usetax is true
    * @param integer $id_customer Customer ID (for customer group reduction)
    * @param integer $id_cart Cart ID. Required when the cookie is not accessible (e.g., inside a payment module, a cron task...)
    * @param integer $id_address Customer address ID. Required for price (tax included) calculation regarding the guest localization
    * @param variable_reference $specificPriceOutput. If a specific price applies regarding the previous parameters, this variable is filled with the corresponding SpecificPrice object
    * @param boolean $with_ecotax insert ecotax in price output.
    * @return float Product price
    */
        public static function getPriceStatic($id_product, $usetax = true, $id_product_attribute = null, $decimals = 6, $divisor = null,
        $only_reduc = false, $usereduc = true, $quantity = 1, $force_associated_tax = false, $id_customer = null, $id_cart = null,
        $id_address = null, &$specific_price_output = null, $with_ecotax = true, $use_group_reduction = true, Context $context = null,
        $use_customer_price = true)
    {
        if (!$context) {
            $context = Context::getContext();
        }
        $cur_cart = $context->cart;

        if ($divisor !== null) {
            Tools::displayParameterAsDeprecated('divisor');
        }

        if (!Validate::isBool($usetax) || !Validate::isUnsignedId($id_product)) {
            die(Tools::displayError());
        }

        // Initializations
        $id_group = null;
        if ($id_customer) {
            $id_group = Customer::getDefaultGroupId((int)$id_customer);
        }
        if (!$id_group) {
            $id_group = (int)Group::getCurrent()->id;
        }

        // If there is cart in context or if the specified id_cart is different from the context cart id
        if (!is_object($cur_cart) || (Validate::isUnsignedInt($id_cart) && $id_cart && $cur_cart->id != $id_cart)) {
            /*
            * When a user (e.g., guest, customer, Google...) is on PrestaShop, he has already its cart as the global (see /init.php)
            * When a non-user calls directly this method (e.g., payment module...) is on PrestaShop, he does not have already it BUT knows the cart ID
            * When called from the back office, cart ID can be inexistant
            */
            if (!$id_cart && !isset($context->employee)) {
                die(Tools::displayError());
            }
            $cur_cart = new Cart($id_cart);
            // Store cart in context to avoid multiple instantiations in BO
            if (!Validate::isLoadedObject($context->cart)) {
                $context->cart = $cur_cart;
            }
        }

        $cart_quantity = 0;
        if ((int)$id_cart) {

            $cache_id = 'Product::getPriceStatic_'.(int)$id_product.'-'.(int)$id_cart;
            if (!Cache::isStored($cache_id) || ($cart_quantity = Cache::retrieve($cache_id) != (int)$quantity)) {
                $sql = 'SELECT SUM(`quantity`)
                FROM `'._DB_PREFIX_.'cart_product`
                WHERE `id_product` = '.(int)$id_product.'
                AND `id_cart` = '.(int)$id_cart;

                $cart_quantity = (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
                Cache::store($cache_id, $cart_quantity);
            } else {
                $cart_quantity = Cache::retrieve($cache_id);
            }
        }

        $id_currency = Validate::isLoadedObject($context->currency) ? (int)$context->currency->id : (int)Configuration::get('PS_CURRENCY_DEFAULT');

        // retrieve address informations
        $id_country = (int)$context->country->id;
        $id_state = 0;
        $zipcode = 0;

        if (!$id_address && Validate::isLoadedObject($cur_cart)) {
            $id_address = $cur_cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')};
        }

        if ($id_address) {
            $address_infos = Address::getCountryAndState($id_address);
            if ($address_infos['id_country']) {
                $id_country = (int)$address_infos['id_country'];
                $id_state = (int)$address_infos['id_state'];
                $zipcode = $address_infos['postcode'];
            }
        } elseif (isset($context->customer->geoloc_id_country)) {
            $id_country = (int)$context->customer->geoloc_id_country;
            $id_state = (int)$context->customer->id_state;
            $zipcode = $context->customer->postcode;
        }

        if (Tax::excludeTaxeOption()) {
            $usetax = false;
        }

        if ($usetax != false
            && !empty($address_infos['vat_number'])
            && $address_infos['id_country'] != Configuration::get('VATNUMBER_COUNTRY')
            && Configuration::get('VATNUMBER_MANAGEMENT')) {
            $usetax = false;
        }

        if (is_null($id_customer) && Validate::isLoadedObject($context->customer)) {
            $id_customer = $context->customer->id;
        }
        
        include_once(dirname(__FILE__).'../../../modules/categoryquantitydiscount/categoryquantitydiscount.php');
        $cqd = new CategoryQuantityDiscount();
        
        $return = Product::priceCalculation(
            $context->shop->id,
            $id_product,
            $id_product_attribute,
            $id_country,
            $id_state,
            $zipcode,
            $id_currency,
            $id_group,
            $cqd->getRealQuantity($id_product, $id_cart, $quantity),
            $usetax,
            $decimals,
            $only_reduc,
            $usereduc,
            $with_ecotax,
            $specific_price_output,
            $use_group_reduction,
            $id_customer,
            $use_customer_price,
            $id_cart, 
            $cqd->getRealQuantity($id_product, $id_cart, $quantity)
        );
        
        return $return;
    }

}

Ese es el que viene dentro del módulo, pero dentro de https hay otros archivos que se llaman product.php

 

Link to comment
Share on other sites

A ver, intento explicarlo:

El archivo /httpdocs/classes/Product.php es el original de Prestashop. Ése no se debe tocar.

Cuando quieres modificar ese archivo, o cualquier otro de las clases de Prestashop, como los originales no se deben tocar, se pueden "extender" para añadir las modificaciones. Para extenderlos, hay que ponerlos dentro de la carpeta /override, con la misma ruta donde están los originales. Por ejemplo, /httpdocs/override/classes/Product.php.

El módulo que quieres instalar necesita extender ese archivo (product.php), por lo que te pide que copies el archivo con el override a esa carpeta, pero la cuestión es que ya tienes ahí alguna modificación, bien hecha por otro módulo o por alguna personalización que te han hecho en la tienda. Así que no puedes sobreescribir ese archivo sin más, sino que debes mezclar el contenido de ambos archivos.

Si quieres adjunta en un post ambos archivos: el que ya tienes en /override/classes, y el que te indica el módulo que debes copiar allí (que creo que es el que has pegado arriba), y te indico cómo mezclarlos.

Edited by Prestafan33 (see edit history)
Link to comment
Share on other sites

  • 1 year later...
  • 2 months later...

Buenas, yo lo acabo de hacer con la última versión de prestashop a día de hoy: 1.7.7.5 sin ningún problema con las reglas del carrito, en catálogo/descuentos.

Creas una regla nueva, en Nombre pones el nombre del descuento que se verá a la hora de finalizar la compra en el carrito:
imagen.thumb.png.1772043c6a3547e33184a3ba6e5d2e46.png
 

En condiciones marcas a que o quienes va a afectar los descuentos, en mi ejemplo puse 2000 unidades disponibles 5 por usuario, seleccionas el producto al que va el descuento, en mi caso a todos productos de una marca puedes seleccionar una categoria o lo que sea, IMPORTANTE, poner el número de productos para que se aplique el descuento, en mi caso 3 unidades:
imagen.thumb.png.de9c87623365323ec2672f485667de3c.png

Y por último la accion, puedes poner el descuento en importe o porcentaje, en mi caso 15% y esto también es importante, aplicar descuento a productos selecionados, sino te lo aplicará a todos los productos del carrito, guardas y listo!!

imagen.thumb.png.9b3d25d175d071a5c9d7b96bb85a9361.png

  • Thanks 1
Link to comment
Share on other sites

  • 10 months later...
On 6/24/2021 at 3:21 PM, Mianviru20 said:

Buenas, yo lo acabo de hacer con la última versión de prestashop a día de hoy: 1.7.7.5 sin ningún problema con las reglas del carrito, en catálogo/descuentos.

Creas una regla nueva, en Nombre pones el nombre del descuento que se verá a la hora de finalizar la compra en el carrito:
imagen.thumb.png.1772043c6a3547e33184a3ba6e5d2e46.png
 

En condiciones marcas a que o quienes va a afectar los descuentos, en mi ejemplo puse 2000 unidades disponibles 5 por usuario, seleccionas el producto al que va el descuento, en mi caso a todos productos de una marca puedes seleccionar una categoria o lo que sea, IMPORTANTE, poner el número de productos para que se aplique el descuento, en mi caso 3 unidades:
imagen.thumb.png.de9c87623365323ec2672f485667de3c.png

Y por último la accion, puedes poner el descuento en importe o porcentaje, en mi caso 15% y esto también es importante, aplicar descuento a productos selecionados, sino te lo aplicará a todos los productos del carrito, guardas y listo!!

imagen.thumb.png.9b3d25d175d071a5c9d7b96bb85a9361.png

 

Confirmo que esta es la opción más útil. Por algún motivo que aún no pillo, esto no me funcionó con el criterio Marcas, pero sí con Categorías. ¡Gracias por el aporte!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...