Jump to content

Adding a label to Minimum quantity


Mark C

Recommended Posts

On the guest and customer's view, the product page will show "The minimum purchase order quantity for the product is xxxx."

How can i append a unit like Liters or pcs so it will look like "The minimum purchase order quantity for the product is xxxx Liters." ?

thanks

Link to comment
Share on other sites

7 minutes ago, Mark C said:

Is it possible to be a variable? One product is in pieces while others are in Liters

If it's variable there's no quick-and-easy way as far as I know, you'd need a custom module or at least some overrides/template modifications, or I guess you could do it some hacky way with JS and a hidden element in the product description or something containing the correct unit for the product.

Just thinking out loud 😄

Link to comment
Share on other sites

This is interesting topic. As the "Liters" or "Pieces" are unit entities and they are attached to product. So, we can use their data in front templates. But it should be tested. I recommend you at first step to dump all data about the product in front template file and look for the unit data. If it is there you can use it easily.

Link to comment
Share on other sites

You Need to Assign the stock data as per the product on the controllers/front/ProductController.php , and use the same on "/themes/{Your-theme}/templates/catalog/_partials/product-add-to-cart.tpl".

 

On the Above tpl file,  Add the HTMLcontent , even you can add js changes in the "themes/{Your-theme}/assets/js/theme.js".

Link to comment
Share on other sites

If you want to creata a field for Litre in the Admin product page, so it wil be better if you use the hook "hookDisplayAdminProductsExtra" like,

public function hookDisplayAdminProductsExtra($params)
    {
               //Your code
               return $this->display(__FILE__, 'views/templates/admin/tpl_name.tpl');
    }

->You can save the data using the hook "hookActionProductSave" like,

public function hookActionProductSave($params)
    {
               //Your code
    }

As if you add the same next to the "Minimum quantity for sale", it will be very complex prcess.

Link to comment
Share on other sites

On 7/20/2022 at 2:20 AM, Knowband Plugins said:

You Need to Assign the stock data as per the product on the controllers/front/ProductController.php , and use the same on "/themes/{Your-theme}/templates/catalog/_partials/product-add-to-cart.tpl".

 

On the Above tpl file,  Add the HTMLcontent , even you can add js changes in the "themes/{Your-theme}/assets/js/theme.js".

from this idea, I think I can use the "unity" column. I will just edit the tpl file in "/themes/{Your-theme}/templates/catalog/_partials/product-add-to-cart.tpl". Is this code below correct?

{l
          s='The minimum purchase order quantity for the product is %quantity% %unity%.'
          d='Shop.Theme.Checkout'
          sprintf=['%quantity%' => $product.minimal_quantity, '%unity%' => $product.unity]
          }

Edited by Mark C (see edit history)
Link to comment
Share on other sites

On 7/27/2022 at 1:01 PM, Mark C said:

from this idea, I think I can use the "unity" column. I will just edit the tpl file in "/themes/{Your-theme}/templates/catalog/_partials/product-add-to-cart.tpl". Is this code below correct?

{l
          s='The minimum purchase order quantity for the product is %quantity% %unity%.'
          d='Shop.Theme.Checkout'
          sprintf=['%quantity%' => $product.minimal_quantity, '%unity%' => $product.unity]
          }

Yes It is correct, it will result as : https://nimb.ws/LSUbEq

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...