Set default product weight?

  • Posts: 21
  • Thank you received: 0
12 years 9 months ago #47061

Quick question:
Is it possible to set a default weight for all (new) products?
I'm trying to streamline the process of entering new products for the user. All products weigh the same so I'd like that weight to be already specified when creating a new product, rather than the user having to set it every time (if they forget, the shipping doesn't work at checkout).
It's not an important requirement; just a 'nice to have' if possible.
So, possible?
Cheers,
Frank

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
12 years 9 months ago #47146

Hi FranksBank,

You can set a default value by editing the code.
Edit the file: YourSite/Administrator/component/com_hikashop/views/product/tmpl/common.php

And change the value of the product weight (l.48) from:

value="<?php echo @$this->element->product_weight;?>"
To
value="<?php if(@$this->element->product_weight != "0.000"){echo @$this->element->product_weight;}else{echo "3.000";} ?>"
Edit the value of "3.000" to what you want.

Last edit: 12 years 9 months ago by Xavier.

Please Log in or Create an account to join the conversation.

  • Posts: 21
  • Thank you received: 0
12 years 9 months ago #47156

Thanks Xavier. I made the change but now when I try to add a new product, the weight field is empty. What's even more odd, is that having reversed the change and put the original code/file back in place, it's still blank. Yoiks! Any ideas?

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
12 years 9 months ago #47161

By default the weight field is empty.

Try to change the value to:

value="<?php if($this->element->product_weight != null){echo @$this->element->product_weight;}else{echo "3.000";} ?>"

The following user(s) said Thank You: FranksBank

Please Log in or Create an account to join the conversation.

  • Posts: 21
  • Thank you received: 0
12 years 9 months ago #47162

Ahhh! Ok. My stupid fault/oversight. I've just had to go through an exercise of adding weights to 500 products, and got used to seeing "0.000" in the fields when I went in to amend. I forgot the field was blank for a new one. Sorry for that panic!

That new 'null' line works a treat. Thank you! :)

Do you happen to know if this can be done as an override (so I don't lose the setting of an upgrade comes in)? If so, what should the folder structure be within my template/html/?

Please Log in or Create an account to join the conversation.

  • Posts: 83103
  • Thank you received: 13418
  • MODERATOR
12 years 9 months ago #47178

You can edit the file "common" of the view "product" of your BACK END template via the menu Display->Views for that.

Please Log in or Create an account to join the conversation.

  • Posts: 21
  • Thank you received: 0
12 years 9 months ago #47187

Of course, yes. I should have had a look for it there.

Problem though. Adding the adjusted line there doesn't work. The code hint (see image below) suggests an issue with the double quotes (tried the _QQ_ workaround but doesn't fix it). Interestingly, the exact same code works if I remove the override and go back to adjusting/uploading the original file. If I then look at the replaced code through Display->Views (what it now thinks is its original) the same code hint is there but the value shows correctly for a new product. Something to do with any override being ignored owing to the code hint issue perhaps?



I've left the 'amended original' in place for now as it works well. Would be great if the override worked; but not a major problem in the scheme of things.

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 83103
  • Thank you received: 13418
  • MODERATOR
12 years 9 months ago #47372

You should add that code BEFORE the <input tag.

Please Log in or Create an account to join the conversation.

Time to create page: 0.085 seconds
Powered by Kunena Forum