News:

Support the VirtueMart project and become a member

Main Menu

calculate automatically the sales price

Started by bluesheep, February 09, 2012, 15:07:53 PM

Previous topic - Next topic

bluesheep

Thanks a lot  ;D

Is there a way, to calculate automatically the sales price (with the product specification price)?

Beste Grüsse
bluesheep

PRO

Quote from: bluesheep on February 09, 2012, 15:07:53 PM
Thanks a lot  ;D

Is there a way, to calculate automatically the sales price (with the product specification price)?

Beste Grüsse
bluesheep

NO,.


and explain what you are trying to do, and why.

bluesheep

Okey, but i solved my Problem.

I try to explain: We have products that are only available in three variants. The variants are:
Var1: 1x Product
Var2: 1x Product + x$ for the work
Var3: 2x Product + y$ for the work
The x$ and y$ are defined by the puglin "product specification".

How i solved (works fine for me) the problem:
First, i created a new view of the productdetails default.php. My new_default.php:

echo $this->currency->createPriceDiv ( 'variantModification', 'COM_VIRTUEMART_PRODUCT_VARIANT_MOD', $this->product->prices );
echo $this->currency->createPriceDiv ( 'basePriceWithTax', 'COM_VIRTUEMART_PRODUCT_BASEPRICE_WITHTAX', $this->product->prices );
echo $this->currency->createPriceDiv ( 'discountedPriceWithoutTax', 'COM_VIRTUEMART_PRODUCT_DISCOUNTED_PRICE', $this->product->prices );
echo $this->currency->createPriceDiv ( 'salesPriceWithDiscount', 'COM_VIRTUEMART_PRODUCT_SALESPRICE_WITH_DISCOUNT', $this->product->prices );
echo $this->currency->createPriceDiv ( 'salesPrice', 'COM_VIRTUEMART_PRODUCT_SALESPRICE', $this->product->prices );
echo $this->currency->createPriceDiv ( 'priceWithoutTax', 'COM_VIRTUEMART_PRODUCT_SALESPRICE_WITHOUT_TAX', $this->product->prices );
echo $this->currency->createPriceDiv ( 'discountAmount', 'COM_VIRTUEMART_PRODUCT_DISCOUNT_AMOUNT', $this->product->prices );
echo $this->currency->createPriceDiv ( 'taxAmount', 'COM_VIRTUEMART_PRODUCT_TAX_AMOUNT', $this->product->prices ); ?>
</div>
<div class="product-fields">
<?php foreach ($this->product->customfieldsCart as $field) { ?>
<?php
[color=red]$abfragefeldtyp $field->field_type;
$gesucht 'E';[/color]
?>

<div class="product-field product-field-type-<?php echo $field->field_type ?>">
<span class="product-fields-title" ><b><?php echo  JText::_($field->custom_title?></b></span>
<span class="product-field-display">[color=red]<?php if ($abfragefeldtyp == $gesucht) echo $field->display ?>[/color]</span>
<span class="product-field-desc"><?php echo $field->custom_field_desc ?></span>
</div><br />
<?php
}
?>

</div>
<?php }
?>


and my new customfields.php

} else if ($group->field_type == 'E'){
                                        $group->display ='';
                                        foreach ($group->options as $productCustom)
                                        $abfrage = $group->custom_tip;

                                        {
                                                if ((float)$productCustom->custom_price ) $price = $currency->priceDisplay($calculator->calculateCustomPriceWithTax($productCustom->custom_price+($product->product_price)*$abfrage));
                                                else  $price = $free ;
                                                $productCustom->text =  $productCustom->custom_value.' '.$price;
//// plugin
                                                if(!class_exists('vmCustomPlugin')) require(JPATH_VM_PLUGINS.DS.'vmcustomplugin.php');
                                                JPluginHelper::importPlugin('vmcustom');
                                                $dispatcher = JDispatcher::getInstance();
                                                $fieldsToShow = $dispatcher->trigger('plgVmOnDisplayProductVariantFE',array($productCustom,&$row,&$group));

                                                $group->display .= '<input type="hidden" value="'.$productCustom->value.'" name="customPrice['.$row.']['.$group->virtuemart_custom_id.']" /> '.JText::_('COM_VIRTUEMART_CART_PRICE').' '.$price ;
                                                $row++;


In the new_default.php i get the field typ P or E to change the view. When P it shows only the title, with E its show all.
In the customfield.php i change the calculation for the price. First, i take the custom_tip (i don't need it to display), its 1 or 2. 1 or 2 to are saved in the config of the customfields. Second, i modified the calculation in "custom_price+($product->product_price)*$abfrage)" --- $abfrage means the 1 or 2.

I hope, you now what i mean in my rusty english.

Beste Grüsse
bluesheep

How it shows: