News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

[SOLVED] Override Price + Custom Field Price Together VM3.8.8

Started by lman, December 13, 2021, 16:54:52 PM

Previous topic - Next topic

lman

QuoteHello

I have print an array and found that the custom field price I want to get is the price of the custom field id: 12610

What I want is to edit: /administrator/components/com_virtuemart/helpers/calculationh.php
and replace the line 406: $this->productPrices['discountedPriceWithoutTax'] = $product_override_price;

with this line: $this->productPrices['discountedPriceWithoutTax'] = $product_override_price + {CUSTOM FIELD 12610 PRICE}; in order to bypass the overriden cost

I need help to get the price of the custom field 12610

Thanks in advance

Found the solution my self:
Hacked File: /administrator/components/com_virtuemart/helpers/calculationh.php
Line (in about): 717 -> Uncomment the following if it's commented: $variantmod = $customfieldModel->calculateModificators($this->_cart->products[$cprdkey], $this->_cart);

Line (in about): 732
If you want this for all shopper groups the replace: $this->_cart->cartPrices['salesPrice'] += $this->_cart->products[$cprdkey]->allPrices[$selectedPrice]['subtotal_with_tax'];
With: $this->_cart->cartPrices['salesPrice'] += $this->_cart->products[$cprdkey]->allPrices[$selectedPrice]['subtotal_with_tax'] + ($variantmod*$this->_amountCart);

UPDATE 2022
In LINE 732 remove the previous code that I have give you and add the following code:
$ammountproiontos = $this->_product->amount;
$this->_cart->cartPrices['salesPrice'] += $this->_cart->products[$cprdkey]->allPrices[$selectedPrice]['subtotal_with_tax'] + ($variantmod*$ammountproiontos);

If you want for specific groups, read my code and play with your needs:
//Κώδικας υπολογισμού overrided τιμής + τιμή custom field - ΑΡΧΗ
        $userModel = VmModel::getModel('user');
        $vmuser = $userModel->getCurrentUser();
        $vmgroup = $vmuser->shopper_groups;
       
        if($this->_currencyDisplay->_priceConfig['salesPrice']){
$this->_cart->products[$cprdkey]->allPrices[$selectedPrice]['subtotal_with_tax'] = self::roundInternal($this->_cart->products[$cprdkey]->allPrices[$selectedPrice]['salesPrice'],'salesPrice') * $this->_cart->products[$cprdkey]->quantity;

                if(isset($vmgroup[0]) && isset($vmgroup[1])){
                    if ($vmgroup[0]==3 || $vmgroup[0]==4 || $vmgroup[1]==3 || $vmgroup[1]==4){
    $this->_cart->cartPrices['salesPrice'] += $this->_cart->products[$cprdkey]->allPrices[$selectedPrice]['subtotal_with_tax'] + ($variantmod*$this->_amountCart);
}else{
                        $this->_cart->cartPrices['salesPrice'] += $this->_cart->products[$cprdkey]->allPrices[$selectedPrice]['subtotal_with_tax'];
                        }
                    }elseif(isset($vmgroup[0])){
                    if ($vmgroup[0]==3 || $vmgroup[0]==4){
    $this->_cart->cartPrices['salesPrice'] += $this->_cart->products[$cprdkey]->allPrices[$selectedPrice]['subtotal_with_tax'] + ($variantmod*$this->_amountCart);
}else{
                        $this->_cart->cartPrices['salesPrice'] += $this->_cart->products[$cprdkey]->allPrices[$selectedPrice]['subtotal_with_tax'];
                        }
                    }else{
                    $this->_cart->cartPrices['salesPrice'] += $this->_cart->products[$cprdkey]->allPrices[$selectedPrice]['subtotal_with_tax'];
                    }

$this->_cart->cartPrices[$cprdkey]['subtotal_with_tax'] = $this->_cart->products[$cprdkey]->allPrices[$selectedPrice]['subtotal_with_tax'];
}
        //Κώδικας υπολογισμού overrided τιμής + τιμή custom field - ΤΕΛΟΣ
       
        //ΠΑΛΑΙΟΣ ΚΩΔΙΚΑΣ
        /*if($this->_currencyDisplay->_priceConfig['salesPrice']){
$this->_cart->products[$cprdkey]->allPrices[$selectedPrice]['subtotal_with_tax'] = self::roundInternal($this->_cart->products[$cprdkey]->allPrices[$selectedPrice]['salesPrice'],'salesPrice') * $this->_cart->products[$cprdkey]->quantity;
$this->_cart->cartPrices['salesPrice'] += $this->_cart->products[$cprdkey]->allPrices[$selectedPrice]['subtotal_with_tax'];
$this->_cart->cartPrices[$cprdkey]['subtotal_with_tax'] = $this->_cart->products[$cprdkey]->allPrices[$selectedPrice]['subtotal_with_tax'];
}*/

lman

ok I found it my self. I will work with that now.

echo array_column($product->customfieldsSorted['addtocart'], 'customfield_price')[0];

UPDATE!!!
unfortunately this does not work on calculationh.php, I get an empty array.

I will search it and I will update

lman