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

[Mod] Related Items incorrect price and add to cart puts wrong item in cart

Started by malik0206, January 18, 2013, 18:52:26 PM

Previous topic - Next topic

malik0206

Hi

I'm having lot of issue with the default_relatedproducts.php.
Firstly the styling of this is not clear and can find where this is coming form.
Secondly by default it should show products price but it doesn't and add to cart is missing as well.

Now after searching through the forum i have found some fixes which i thought it solved my problem but it hasn't fixed anything in fact it has created more bugs

This is my code for related items


<?php

// Check to ensure this file is included in Joomla!
defined ( '_JEXEC' ) or die ( 'Restricted access' );

$model = new VirtueMartModelProduct();
$calculator = calculationHelper::getInstance();
$currency = CurrencyDisplay::getInstance();
?>

<div class="product-related">

       <h4><?php echo JText::_('COM_VIRTUEMART_RELATED_PRODUCTS'); ?></h4>

    <?php
    foreach ($this->product->customfieldsRelatedProducts as $field) { ?>
   <div class="related-item product-field-type-<?php echo $field->field_type ?>">
   
   <span class="item-image-title-display"><?php echo $field->display ?></span>
   
    <?php
       foreach ($this->product->customfieldsRelatedProducts as $field) {
   ?>
     
   <?php } ?>
        
   <div class="related-item-price">
      <?php echo jText::_($field->custom_field_desc);
      $product = $model->getProductSingle($field->custom_value,false);
      $price = $calculator -> getProductPrices($product);
      echo $currency->priceDisplay($price['salesPrice']);
      ?>
   </div>


<form method="post" class="product" action="index.php" id="addtocartproduct<?php echo $product->virtuemart_product_id ?>">
   
   <div class="addtocart-bar">   
                  
      <span class="quantity-box">
         <input style="display:none;" type="text" class="quantity-input" name="quantity[]" value="1" />
      </span>
         

         <?php // Add the button
         $button_lbl = JText::_('COM_VIRTUEMART_CART_ADD_TO');
         $button_cls = ''; //$button_cls = 'addtocart_button';
         if (VmConfig::get('check_stock') == '1' && !$this->product->product_in_stock) {
            $button_lbl = JText::_('COM_VIRTUEMART_CART_NOTIFY');
            $button_cls = 'notify-button';
      } ?>

      <?php // Display the add to cart button ?>
      <input type="submit" name="addtocart"  class="addtocart-button" value="<?php echo $button_lbl ?>" title="<?php echo $button_lbl ?>" />

   </div>
   
      <?php // Display the add to cart button END ?>
      <input type="hidden" class="pname" value="<?php echo $product->product_name ?>">
      <input type="hidden" name="option" value="com_virtuemart" />
      <input type="hidden" name="view" value="cart" />
      <noscript><input type="hidden" name="task" value="add" /></noscript>
      <input type="hidden" name="virtuemart_product_id[]" value="<?php echo $product->virtuemart_product_id ?>" />
      <?php /** @todo Handle the manufacturer view */ ?>
      <input type="hidden" name="virtuemart_manufacturer_id" value="<?php echo $product->virtuemart_manufacturer_id ?>" />
      <input type="hidden" name="virtuemart_category_id[]" value="<?php echo $product->virtuemart_category_id ?>" />
</form>

      </div>
      
   <?php } ?>

</div>


i managed to get the price and add to cart button showing on the related items but then what i noticed is that the price is not showing for each individual item instead it show the price for the last related item so all the my related item have the same price.

Also Add to Cart button only adds the the last item in my related items list.

example i have 4 related items now the price is same for all items and the price is taken from the last related item for all items also the add to cart but only adds the 4th item from the list.

if i click Add to Cart on the first related item then in my cart it show the 4th item.

also if i add a 5th related item then it will add the 5 item to the cart and show the price of the 5th item for other 4 items

Can anyone help i really need to launch the site but this is holding me back.

Thanks in advance

Milbo

Hmm, so you add your own idea, it does not work and you describe it as bug? Why you did not wrote as title "How to display price and add to cart for related products?".
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

PRO

lol, for a second there I was wondering when price etc. was added.

malik0206, I assume you got a commercial template from soomeone? Because that code is not default. It would be easier for the person that made the template to help with this