Count Characters for Automatic Entry of Quantity

  • Posts: 10
  • Thank you received: 0
9 years 11 months ago #182444

-- url of the page with the problem -- : horseshoeengraver.com/shop/product/8-custom-lettering
-- HikaShop version -- : 2.3.4
-- Joomla version -- : 2.5.20
-- PHP version -- : 5.5.3
-- Browser(s) name and version -- : ANY

Hi, I am a silversmith (not a programmer) who sells custom engraving for some of my products. I charge a fee per each character that I hand-engrave. Is there a way I can have the customer type their desired inscription in a field and have HikaShop automatically count the number characters in the field in order to automatically enter the correct quantity. (Asking the customers to count the number of characters in their inscriptions never ends well.)
Thanks!

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

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
9 years 11 months ago #182604

Hi,

Here is a small plugin you can install on your website and then configure to set the quantity of the product in the cart to the number of letters of a custom item field that the customer can fill on the product page:

File Attachment:

File Name: custom_pri...ount.zip
File Size:1 KB

Attachments:
The following user(s) said Thank You: jbrandvik, korzo

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

  • Posts: 10
  • Thank you received: 0
9 years 11 months ago #182673

Thanks Nicolas,
I really appreciate you taking the time to create the plugin. This looks like the perfect fix for my problem. Unfortunately when I enable the plug in and put something into my cart, my website no longer displays in Safari. I have disabled all third party modules and plugins and the problem still exists.


Here was my workflow;

1 - Installed the plugin and enabled it changing the input field name "from_field" to "inscription2" and saved.
2 - Created a custom text field in the item table labeled "inscription2" and assigned it to the proper category

The custom text field is then available on the product pages but when I add anything to the cart, any page in the shop of my website fails to display.

Hopefully you will know what the problem is.

Last edit: 9 years 11 months ago by jbrandvik.

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

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
9 years 11 months ago #182700

Hi,

Please turn on the debug mode and error reporting options of the Joomla configuration and try again. What error message do you get when it doesn't work ?
Knowing the error will help me tell you what to do.

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

  • Posts: 10
  • Thank you received: 0
9 years 11 months ago #183025

When the plugin is enabled, this error is generated when going into the Hikashop category page. Strict Standards: Only variables should be assigned by reference in D:\Websites\Skip\horseshoeengraver.com\www\plugins\system\rsseo\rsseo.php on line 373 Fatal error: Call to a member function get() on a non-object in D:\Websites\Skip\horseshoeengraver.com\www\plugins\system\custom_price_letter_count\custom_price_letter_count.php on line 24

Then this error is generated when anything is added to the cart. Fatal error: Call to a member function get() on a non-object in D:\Websites\Skip\horseshoeengraver.com\www\plugins\system\custom_price_letter_count\custom_price_letter_count.php on line 24
Thanks

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

  • Posts: 13201
  • Thank you received: 2322
9 years 11 months ago #183031

Hi,

Please edit the indicated file and replace:

$field = $params->get('field','');
By:
$field = $this->params->get('field','');

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

  • Posts: 10
  • Thank you received: 0
9 years 11 months ago #183126

Changing the file produces this result.
Thank you

Fatal error: Using $this when not in object context in D:\Websites\Skip\horseshoeengraver.com\www\plugins\system\custom_price_letter_count\custom_price_letter_count.php on line 24

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

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
9 years 11 months ago #183190

Hi,

Please install this new version of the plugin and try again. It should work better:

File Attachment:

File Name: custom_pri...2-13.zip
File Size:1 KB

Attachments:
The following user(s) said Thank You: jbrandvik

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

  • Posts: 10
  • Thank you received: 0
9 years 11 months ago #183197

Nicolas,
Thank you, once again for the time you have put into working on this. I am sure there will be many others who will be able to use this plugin if they do any custom work.

This version of the plugin does indeed work without throwing any errors. Unfortunately, I still can't use the it because it counts not only the characters typed in the custom field, it also counts blank spaces. Since the intent is to calculate the correct price for the custom lettering engraved on the product, the plugin would charge the customer for each blank space as well. Example,if the client's requested inscription is ALL MY LOVE , the plugin inputs a quantity of 11 instead of the correct quantity of 9.

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

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
9 years 11 months ago #183200

Hi,

Well that wasn't something clearly explained so I went to the simplest.
Here is a new version with an option to list the characters that you want to be excluded from the counting:

File Attachment:

File Name: custom_pri...13-2.zip
File Size:1 KB

Attachments:
The following user(s) said Thank You: jbrandvik

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

  • Posts: 10
  • Thank you received: 0
9 years 11 months ago #183204

Awesome! Thank you! This is a good example of why I stay with you guys year after year!

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

Time to create page: 0.092 seconds
Powered by Kunena Forum