Jump to content

Change Specific Price to default


Makiavelo

Recommended Posts

Hello, 

I would appreciate if there is someone to help me.

I try to change SpecificPrice to default , but with not succes. When i make an order i can not change the price for the product ( i want to specific at  the created product is whit price 0. ) Product price i get it from an auction modul who have a specific price for the winner.

I have prestashop 1,6 and i have an override file , for cart.

This is the override file for CartControler.php :

class CartController extends CartControllerCore
{
    /*
    
    * date: 2020-04-06 12:23:13
   
    */
    protected function processChangeProductInCart()
    {
        require_once _PS_MODULE_DIR_.'productauction/classes/AuctionDetail.php';
        $customerId = $this->context->cookie->id_customer;
        if ($customerId) {
            $objAuction = new AuctionDetail();
            if (Configuration::get('AUCTION_QUANTITY_RESTRICT')) {
                $auctionWinnerDetails = $objAuction->getAuctionDetailsByWinner($customerId);
                if ($auctionWinnerDetails) {
                    foreach ($auctionWinnerDetails as $auctionWinner) {
                        $idProduct = $auctionWinner['id_product'];
                        $specificPriceData = $objAuction->getSpecificPrice($idProduct, $customerId);
                        if ($specificPriceData) {
                            if ($this->qty > 1) { //customer can't purchase more than one subscription product
                                if ($this->id_product == $idProduct) {
                                    $this->errors[] = Tools::displayError('You can not purchase more than one quantity of auction product.');
                                    break;
                                }
                            } else {
                                $cartProducts = $this->context->cart->getProducts();
                                $found = 0;
                                if (is_array($cartProducts)) {
                                    foreach ($cartProducts as $product) {
                                        if ($this->id_product == $idProduct && $product['id_product'] == $idProduct) {
                                            $this->errors[] = Tools::displayError('You can not purchase more than one quantity of auction product.');
                                            $found = 1;
                                            break;
                                        }
                                    }
                                }
                                if ($found) {
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            if (Configuration::get('AUCTION_BUYNOW_QUANTITY_RESTRICT')) {
                $buyNowProducts = $objAuction->getActiveBuyNowProduct($this->id_product);
                if (!empty($buyNowProducts) && $buyNowProducts['winner_customerid'] == 0) {
                    if ($this->qty > Configuration::get('WK_AUCTION_BUYNOW_QUANTITY_RESTRICT')) {
                        $this->errors[] = Tools::displayError('You can not purchase more than '.Configuration::get('AUCTION_BUYNOW_QUANTITY_RESTRICT').' quantity of auction product.');
                    } else {
                        $cartProducts = $this->context->cart->getProducts();
                        if (is_array($cartProducts)) {
                            foreach ($cartProducts as $product) {
                                if ($product['id_product'] == $this->id_product
                                    && $product['quantity'] + $this->qty > Configuration::get(
                                        'AUCTION_BUYNOW_QUANTITY_RESTRICT'
                                    )
                                    && (!Tools::getIsset('op') || Tools::getIsset('add'))
                                ) {
                                    $this->errors[] = Tools::displayError('You can not purchase more than '.Configuration::get('AUCTION_BUYNOW_QUANTITY_RESTRICT').' quantity of auction product.');
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }
        parent::processChangeProductInCart();
    }
}

Thank you

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...