1

I am trying to add custom text after price display everywhere(globally) in website.

  1. category view
  2. product view
  3. Mini cart
  4. cart page
  5. checkout page etc..

can anyone help to me...

1

3 Answers 3

0

Please try to override Magento/Catalog/view/base/templates/product/price/amount/default.phtml from core vendor to your theme path and added the text in the above or after rendering price.

1
  • Yes, but it will only change in product view page .I need everywhere in cart checkout etc... Commented Jul 10, 2019 at 8:24
0

This for list page :

Vendor/Module/view/frontend/requirejs-config.js

var config = {
  config: {
    mixins: {
      'Magento_Catalog/js/price-box': {
        'Vendor_Module/js/price-box-mixin': true
      }
    }
  }
};

var/www/html/olystudio/vendor/magento/module-catalog/view/base/web/js/price-box.js

define(['jquery'], function ($) {

  return function (widget) {
    var globalOptions = {
      productId: null,
      priceConfig: null,
      prices: {},
      priceTemplate: '<span class="price"><%- data.formatted %>/ custom-text</span>'
    };

    $.widget('mage.priceBox', widget, {
      options: globalOptions
    });
    return $.mage.priceBox;
  }
});

Checkout Cart and Summary page :

https://webkul.com/blog/display-custom-price-fee-checkout-cart-summary-total-magento2/

I hope its work for you.

0

Certainly! To add custom text after the price display globally throughout your Magento website, you'll need to make some modifications to your theme files. Here's a step-by-step guide:

  1. Backup Your Files:** Before making any changes, it's always a good idea to create a backup of your theme files and database.

  2. Edit Theme Files:** Navigate to your active theme directory in the Magento installation. The path is usually app/design/frontend/{Vendor}/{Theme}/.

  3. Locate Price Templates:** Inside your theme directory, look for the template files responsible for rendering prices. The most common files are:

    • template/catalog/product/price.phtml (for product view)
    • template/checkout/cart/item/default.phtml (for mini cart)
    • template/checkout/cart/item/default.phtml (for cart page)
    • template/checkout/cart/totals/default.phtml (for cart and checkout totals)
  4. Edit Template Files:** Open the relevant template files in a code editor.

  5. Find Price Display Code:** Search for the code responsible for displaying the price. This code will vary based on your theme and version but is usually something like <?php echo $_coreHelper->formatPrice($_finalPrice, false) ?>.

  6. Add Custom Text:** Just after the price display code, add your custom text. For example:

    <?php echo $_coreHelper->formatPrice($_finalPrice, false) ?>
    <span class="custom-text">Custom Text Here</span>
    
  7. Apply to Other Templates:** Repeat steps 3-6 for other template files where you want to display the custom text after the price.

  8. CSS Styling:** If needed, style the custom-text class using CSS to make it visually appealing.

  9. Clear Cache:** Clear the Magento cache to see the changes take effect.

Please note that the exact code and files may vary based on your Magento version, theme, and customizations.

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.