0

We have a module that create quotes that very simaler like create orders from backend, add customer, add product/s by select them so you can see them as a list in the backend before you create the order and submit them.

I tried to add more 2 attributes with price value, I can see them under any product on backend with their value. But when I want to see them in the list on backend I got 0$ instead the value of the attribute.

I added to code :

<strong><?php echo $block->escapeHtml(__('Extra Price 1: ')); ?></strong>

<?php $pricingHelper = $this->helper(\Magento\Framework\Pricing\Helper\Data::class); ?>
<?php echo $pricingHelper->currency($product->getData('price_tier_1'), true, false); ?>
<br />

<strong><?php echo $block->escapeHtml(__('Extra Price 2: ')); ?></strong>

<?php $pricingHelper = $this->helper(\Magento\Framework\Pricing\Helper\Data::class); ?>
<?php echo $pricingHelper->currency($product->getData('price_tier_2'), true, false); ?>

any idea why? suggest to solve it and see the correct value that appear in the product information in the backend?

Thanks!

enter image description here Here is all the code that i used (phtml) and the js script part that Hamendra Sunthwal suggested, and it still not show up the value in salesrep_approval_tier_1 / salesrep_approval_tier_2 attrbites.

<?php
    $item = $block->getItem();
    $product = $item->getProduct();
    $tierItem = $item->getTierItem();
    ?>

    <?php $block->setPriceDataObject($item->getTierItem()); ?>
    <?php if ($block->displayPriceExclTax() || $block->displayBothPrices()) : ?>
        <?php  ?>
        <?php if ($block->displayBothPrices()) : ?>
            <span class="label"><?php echo $block->escapeHtml(__('Excl. Tax')) ?>:</span>
        <?php endif; ?>
        <?php echo $block->displayPriceAttribute('original_price'); ?><br /><br />
        <strong><?php echo $block->escapeHtml(__('Approval Tier 1: ')); ?></strong>

/** This is the script that I added - but still it is not show me the value in attrbute 'salesrep_approval_tier_1' */
        <script type="text/javascript">
           require(["jquery"],function($) {
            $(document).ready(function() {
               var dividprice1= $('salesrep_approval_tier_1').val();
                                $('salesrep_approval_tier_1').val(dividprice1);
               });
            });

         </script>
/** This is the end of script that I added */
    <br />
    <strong><?php echo $block->escapeHtml(__('Approval Tier 2: ')); ?></strong>
/** In this soultion - it is show me 0$ instead the value in 'salesrep_approval_tier_2' attribute */

    <?php $pricingHelper = $this->helper(\Magento\Framework\Pricing\Helper\Data::class); ?>
    <?php echo $pricingHelper->currency($product->getData('salesrep_approval_tier_2'), true, false); ?>

/** This is the end to show 'salesrep_approval_tier_2' attribute */

    <?php endif; ?>

    <?php if ($block->displayPriceInclTax() || $block->displayBothPrices()) : ?>
        <?php if ($block->displayBothPrices($block->getStore())) : ?>
            <br /><span class="label"><?php echo $block->escapeHtml(__('Incl. Tax')) ?>:</span>
        <?php endif; ?>
        <?php echo $block->displayPrices(
            $block->getBaseOriginalPriceInclTax($tierItem),
            $block->getOriginalPriceInclTax($tierItem)
        ); ?>
    <?php endif; ?>
    <?php if ($block->getIsSelectedTier() && $product->hasTierPrice() && !empty($product->getTierPrice())) :?>
        <a id="quote-view-advanced-pricing-hover" class="quote-view-advanced-pricing-hover">advanced pricing</a>
            <div id="quote-view-advanced-pricing" class="quote-view-advanced-pricing" hidden>
                <?php echo $block->escapeHtml(__('Advanced Pricing')); ?>
                <ul>
                    <li><?php echo __('Catalog price: %1', $block->formatPrice($product->getPrice())); ?></li>
                    <?php foreach ($product->getTierPrice() as $advancedPrice) :?>
                        <li>
                            <?php echo __(
                                "Qty %1: %2",
                                (int)$advancedPrice['price_qty'],
                                $block->formatPrice($advancedPrice['price'])
                            ); ?>
                        </li>
                    <?php endforeach; ?>
                </ul>
            </div>
    <?php endif;?>
9
  • List on backend ? In backend product grid ? Commented Apr 9, 2020 at 17:42
  • if you go to Sales>orders>Create new order > sign user > add product to order and the list there... I saw it call "data-table admin__table-primary order-tables"
    – Lior Loria
    Commented Apr 9, 2020 at 18:09
  • I added print screen from Quote but it is very simler to orders...
    – Lior Loria
    Commented Apr 9, 2020 at 18:14
  • Try this <?php echo $pricingHelper->currency($product->getPriceTier1(), true, false); ?> Commented Apr 9, 2020 at 18:23
  • If still doesn't work and if only these two attributes are needs to be shown above , use jQuery , get value from the two div below and display in above div. Commented Apr 9, 2020 at 18:25

1 Answer 1

1

Add this js code in the phtml file in which is called in the above page and replace div id and it will work.

require(["jquery"],function($) { $(document).ready(function() { var dividprice1= $('#dividprice1').text(); var dividprice2= $('#dividprice2').text(); //Div id where you want to show price one $('#dividpriceone').val(dividprice1); //Div id where you want to show price two $('#dividpricetwo').val(dividprice2); }); });

8
  • Try and let us know if its helpful and works , give upvote on the answer if it works 4 you, so it will help to others in Magento community. Commented Apr 10, 2020 at 11:23
  • Hi Hamendra, Thanks, but still not get the value, now is show empty not 0...
    – Lior Loria
    Commented Apr 10, 2020 at 21:07
  • Hi Hamendra, I added all the code (phtml) to the last part of my question with the js
    – Lior Loria
    Commented Apr 10, 2020 at 21:57
  • The idea is to show the values that I have in salesrep_approval_tier_1 and salesrep_approval_tier_2 attributes... Big Thank in advance
    – Lior Loria
    Commented Apr 10, 2020 at 21:57
  • 1
    Yes it will show salesrep_approval_tier_1 and salesrep_approval_tier_2 attributes values into the two div's above. This code will take values from those two div and render them into the two div which are above. Let me know it if works for you. Commented Apr 11, 2020 at 6:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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