0

Could you give me a hand in using the custom attribute price rather than the getFinalPrice.

So I have a custom attribute set up called clearance_price which uses "Price"

However, the product has a price set up on the normal "Prices" part of the product and has a custom price set in a custom attribute called "Clearance Information" - this then has clearance_price in.

We're basically using the same product in different sections of the website, once on it's usual category page and once in the clearance page, however clearance are refurbs and sold at a discounted price.

I have the custom attribute price displaying correctly on the page but when I add it to the cart it naturally, brings in the price from the prices tab.

How do I change this to add it to the cart using the custom price?

        <?php

            echo "<div class='c_price'>&pound;"; 
            echo number_format($_product->getClearance_price(), 2, '.', '');
            echo " <span class='c_price_txt'>ex vat</span></div>";

            $percentage = 20;

            $incvatprice = $_product->getClearance_price() * (1 + (20/100));

            echo "<div class='c_price_inc'>&pound;"; 
            echo number_format($incvatprice, 2, '.', '');
            echo " <span class='c_price_txt'>inc vat</span></div>";

            echo "this";
            echo $_product->getFinalPrice();

        ?>


            <?php echo $this->getChildHtml('alert_urls') ?>
            <?php echo $this->getChildHtml('extrahint') ?>

            <?php if (!$this->hasOptions()):?>
                <div class="add-to-box">
                    <?php if($_product->isSaleable()): ?>

                        <div class="row quant">

                        <div class="col-lg-2 col-md-2 col-sm-2 qty_txt"><b>Qty:</b> </div>

                            <div class="minus col-lg-1 col-md-4 cold-sm-4 qty-minus hidden-sm hidden-xs">
                                <i class="fa fa-minus" id="qty-minus"></i>
                            </div>

                            <div class="col-lg-3 col-md-4 cold-sm-4">
                                <input type="text" pattern="\d*" name="qty" id="qty" maxlength="12" value="1" title="Qty" class="input-text qty align-center col-xs-1">
                            </div>

                            <div class="plus col-lg-1 col-md-4 cold-sm-4 qty-plus hidden-sm hidden-xs">
                                <i class="fa fa-plus" id="qty-plus"></i>
                            </div>

                        </div> <!-- end row -->

                        <div class="row">
                            <div class="col-lg-12 col-md-12 col-sm-12">
                                <button type="button" title="<?php echo $this->__('Add to Basket') ?>" class="addbutton button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span class="addit"><?php echo $this->__('Add to Basket') ?></span></span></button>
                            </div>
                        </div> <!-- end row -->

                    <?php endif; ?>
                </div>

1 Answer 1

0

It's not as easy as echoing it in the cart, to really use it as the product price in such a way that it also goes to the payment provider you'll need to make an observer-module to hook in to that payment-gateway process, you could start with this answer.

But seeing your idea on how to use the prices, wouldn't you be better and easier off to use the 'special sale price' conditions, which are already in the core?

4
  • Hi, Thanks for your answer. Wouldn't using the special sale price also change the price on it's original category aswell? We want the same product listed twice in different categories with different prices. I'm not too familiar with magento, so learning as I go.
    – Blake
    Jul 1, 2016 at 9:42
  • Ah I see. Well this is kind of what I wanted to do with different currencies ( stackoverflow.com/questions/29432936/… ) but after a lot of research I found it was rather impossible to have multiple prices for a product, unless it's some kind of percentage. Which if this is the case (say you want to have a 15% discount on the products only in category X), you could look at this; magento.stackexchange.com/a/9447/37536
    – Asitis
    Jul 1, 2016 at 9:49
  • 1
    That actually helps, as we set a percentage price in our local database which is then uploaded, so we may be able to do it like this - thanks i'll let you know how I get on!
    – Blake
    Jul 1, 2016 at 10:42
  • Nice :) Glad to help. If it's the same percentage everywhere, it's way easier to set it with a price rule for a specific category, as you'll only have to keep that one percentage up to date, in stead of managing different prices for all products.
    – Asitis
    Jul 1, 2016 at 10:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.