@@ -537,33 +537,31 @@ public virtual decimal GetUnitPrice(Product product,
537537 //needed for VAT calculation of product bundles
538538 //taxrate comes from associated product and not from product
539539 decimal attributesTotalPrice = decimal . Zero ;
540- if ( combination != null )
540+ var attributeValues = _productAttributeParser . ParseProductAttributeValues ( attributesXml ) ;
541+ if ( attributeValues != null )
541542 {
542- var attributeValues = _productAttributeParser . ParseProductAttributeValues ( attributesXml ) ;
543- if ( attributeValues != null )
543+ decimal taxRate ;
544+ foreach ( var attributeValue in attributeValues )
544545 {
545- decimal taxRate ;
546- foreach ( var attributeValue in attributeValues )
547- {
548- var attributePrice = GetProductAttributeValuePriceAdjustment ( attributeValue ) ;
549- attributesTotalPrice += attributePrice ;
546+ var attributePrice = GetProductAttributeValuePriceAdjustment ( attributeValue ) ;
547+ attributesTotalPrice += attributePrice ;
550548
551- if ( attributeValue . AttributeValueType == AttributeValueType . AssociatedToProduct )
549+ if ( attributeValue . AttributeValueType == AttributeValueType . AssociatedToProduct )
550+ {
551+ //bundled product
552+ var associatedProduct = _productService . GetProductById ( attributeValue . AssociatedProductId ) ;
553+ if ( associatedProduct != null )
552554 {
553- //bundled product
554- var associatedProduct = _productService . GetProductById ( attributeValue . AssociatedProductId ) ;
555- if ( associatedProduct != null )
556- {
557- //get only the taxrate of associate product, price is not needed
558- var attributePriceTax = _taxService . GetProductPrice ( associatedProduct , 0 , customer , out taxRate ) ;
559- //build taxSummary for tax subdivision
560- taxWeightSummary . AddRate ( taxRate , attributePrice ) ;
561- }
555+ //get only the taxrate of associate product, price is not needed
556+ var attributePriceTax = _taxService . GetProductPrice ( associatedProduct , 0 , customer , out taxRate ) ;
557+ //build taxSummary for tax subdivision
558+ taxWeightSummary . AddRate ( taxRate , attributePrice ) ;
562559 }
563560 }
564561 }
565562 }
566563
564+
567565 if ( combination != null && combination . OverriddenPrice . HasValue )
568566 {
569567 finalPrice = GetFinalPrice ( product ,
@@ -618,17 +616,17 @@ public virtual decimal GetUnitPrice(Product product,
618616 if ( _shoppingCartSettings . RoundPricesDuringCalculation )
619617 finalPrice = RoundingHelper . RoundPrice ( finalPrice ) ;
620618
621- //add tax attributes
619+ //add tax attributes if needed
622620 if ( taxWeightSummary != null && taxWeightSummary . TaxRates . Any ( ) )
623621 {
624622 decimal prodcutTaxRate ;
625- //get taxrate, no price needed
626- var itemAmount = _taxService . GetProductPrice ( product , 0 , customer , out prodcutTaxRate ) ;
623+ //get taxrate and product price
624+ var productPrice = _taxService . GetProductPrice ( product , product . Price , customer , out prodcutTaxRate ) ;
627625
628626 //price is overridden or it is product price + attributes price
629- if ( combination != null && ! combination . OverriddenPrice . HasValue )
627+ if ( combination == null || combination != null && ! combination . OverriddenPrice . HasValue )
630628 {
631- var baseProductPrice = finalPrice - attributesTotalPrice ;
629+ var baseProductPrice = productPrice ; // finalPrice - attributesTotalPrice;
632630 //add product price if exists
633631 if ( baseProductPrice > decimal . Zero )
634632 taxWeightSummary . AddRate ( prodcutTaxRate , baseProductPrice ) ;
0 commit comments