Make Checkboxes in Prestashop Using helpers

Make Checkboxes in Prestashop Using helpers

Make Checkboxes in Prestashop Using helpers

Today I was working on a module and I noticed that there is a barrier to doing checkboxes in Prestashop using the helpers they provide. I did however, find some help through the watermark module created by Prestashop that uses checkboxes as directed by some on the Prestashop forum see it by clicking here -> https://www.prestashop.com/forums/topic/351691-show-helper-form-checkbox-checked/. Now it seemed quite complex and I believe this may become over cumbersome for those who do not develop regularly. so I decided to create this tutorial to help others in their developing endeavors.

***This tutorial assumes you already know how to create a form using the helpers and can add all the required information to build around the input array you see below. You can start by adding the check box input array below

array( 'type' => 'checkbox', 'label' => $this->l('Options'), 'desc' => $this->l('Choose options to use during regeneration or generation of product references. The module processes like this-> (Reference will equal or be generated to be as follows with | separating each section of the custom inputs and the product based information.) Reference -> customidentifier|customsymbolpos1|(random number from 1-999)|customsymbolpos2|itemid|itemcategoryid|customsymbolpos3|itemsupplierid|customsymbolpos4|current reference only **NOT Supplier reference <---. please="" leave="" custom="" fields="" blank="" if="" you="" want="" to="" not="" provide="" any="" identifiers="" or="" characters="" name=""> 'options', 'values' => array( 'query' => $this->getOptions(), 'id' => 'id_checkbox_options', 'name' => 'checkbox_options_name', 'expand' => array( 'print_total' => count($this->getOptions()), 'default' => 'show', 'show' => array('text' => $this->l('show'), 'icon' => 'plus-sign-alt'), 'hide' => array('text' => $this->l('hide'), 'icon' => 'minus-sign-alt') ), ), ), 

After that we need to create the query for the checkboxes available. 

public function getOptions() { $options = array ( array ( 'id_checkbox_options' => 0, 'checkbox_options_name' => 'Option 0'), array ( 'id_checkbox_options' => 1, 'checkbox_options_name' => 'Option 1'), array ( 'checkbox_options_options' => 2, 'checkbox_options_name' => 'Option 2'), array ( 'checkbox_options_options' => 3, 'checkbox_options_name' => 'Option 3'), array ( 'id_checkbox_options' => 4, 'checkbox_options_name' => 'option 4') ); return $options; } 

Now we get and save the information from checkboxes after posting or saving the form.

private function _postProcess() { $output = ''; if (Tools::isSubmit('submitBtn')) { Configuration::updateValue('checkbox_text_demo', Tools::getValue('checkbox_text_demo')); $all_opts = $this->getOptions(); $checkbox_options = array(); foreach ($all_opts as $chbx_options) if (Tools::getValue('options_'.(int)$chbx_options['id_checkbox_options'])) $checkbox_options[] = $chbx_options['id_checkbox_options']; Configuration::updateValue('options', implode(',', $checkbox_options)); $output .= $this->displayConfirmation($this->l('Settings updated')); } } 

Lastly, we load the submitted information into checkboxes as we load the form along with other field variables.

protected function getConfigFormValues() { $config_fields = array ( 'checkbox_text_demo' => Configuration::get('checkbox_text_demo'), // if you have other fields to fill this would fill text input field. ); //get all checkbox stuff all available $opts = $this->getOptions(); $id_checkbox_options = array(); foreach ($opts as $options) $id_checkbox_options[] = $options['id_checkbox_options']; //get checkbox stuff from $_POST $id_checkbox_options_post = array(); foreach ($id_checkbox_options as $opt_id) if (Tools::getValue('options_'.(int)$opt_id)) $id_checkbox_options_post['options_'.(int)$opt_id] = true; //get checkbox stuff from Configuration $id_checkbox_options_config = array(); if ($confs = Configuration::get('options')) $confs = explode(',', Configuration::get('options')); else $confs = array(); foreach ($confs as $conf) $id_checkbox_options_config['options_'.(int)$conf] = true; //return only common values and value from post if (Tools::isSubmit('submit_Btn')) $config_fields = array_merge($config_fields, array_intersect($id_checkbox_options_post, $id_checkbox_options_config)); else $config_fields = array_merge($config_fields, $id_checkbox_options_config); return $config_fields; } 

That's it!

I know it is a lot and very confusing to some so for this tutorial we have a comments section to allow you to ask question and get help with your works. Please ask away and I hope this helps you.

author: William Williamson

date: 12-24-2015

59 Comments

    • Avatar
      Evelyne

      Your site can go viral, you need some initial traffic only. How to do that? Search in google for: Willard's Tips SM Traffic

    • Avatar
      seo

      Hello Web Admin, I noticed that your On-Page SEO is is missing a few factors, for one you do not use all three H tags in your post, also I notice that you are not using bold or italics properly in your SEO optimization. On-Page SEO means more now than ever since the new Google update: Panda. No longer are backlinks and simply pinging or sending out a RSS feed the key to getting Google PageRank or Alexa Rankings, You now NEED On-Page SEO. So what is good On-Page SEO?First your keyword must appear in the title.Then it must appear in the URL.You have to optimize your keyword and make sure that it has a nice keyword density of 3-5% in your article with relevant LSI (Latent Semantic Indexing). Then you should spread all H1,H2,H3 tags in your article.Your Keyword should appear in your first paragraph and in the last sentence of the page. You should have relevant usage of Bold and italics of your keyword.There should be one internal link to a page on your blog and you should have one image with an alt tag that has your keyword....wait there's even more Now what if i told you there was a simple Wordpress plugin that does all the On-Page SEO, and automatically for you? That's right AUTOMATICALLY, just watch this 4minute video for more information at. Seo Plugin

    • Avatar
      healthy choice garcinia cambogia free trial

      Excellent, what a blog it is! This website provides useful facts to us, keep it up.

      • Avatar
        William Williamson
        Apr 10, 2016

        Thank you, we are working on some great new articles, tutorials and a new blog design that will help us all to engage more and be able to keep the discussions going.Thank you, William

    • Avatar
      Nereida

      I do trust all the concepts you've offered to your post. They're very convincing and will certainly work. Still, the posts are too short for starters. May just you please prolong them a bit from next time? Thank you for the post.

      • Avatar
        William Williamson
        Apr 10, 2016

        Thank you for your advice I will definitely do that.Thank you, William

    • Avatar
      Kara

      Duct tape can be a camper's very best friend.

      • Avatar
        William Williamson
        Apr 10, 2016

        Indeed it can!!!

    • Avatar
      http://google.co.uk/contrar32/

      '' It's also essental to Arizona State guiidelines to present a legitimate ID plus an Arizona car title loans owed to the owner of the car you need to take a loan from, along with staying at the very least 17 years old Comparing Quick unsecured loans are the best supply of cheap in addition to affordable financial loans for your basic needs

      • Avatar
        William Williamson
        Apr 10, 2016

        Thank you for the extra information I am sure someone will use it.Thank you, William

    • Avatar
      homes for sale thurston county wa Washington real estate

      HM

    • Avatar
      Lorenzo

      Thanks for finally writing about >Make Checkboxes in Prestashop Using helpers

      • Avatar
        William Williamson
        Apr 10, 2016

        you are very welcome glad it helped you out.Thank you, William

    • Avatar
      Lauri

      My brother recommended I might like this web site. He was entirely right. This publish actually made my day. You cann't imagine simply how a lot time I had spent for this info! Thank you!

      • Avatar
        William Williamson
        Apr 10, 2016

        I am so glad your brother and you liked the website and found our articles useful. We are working on some new articles, adding more products that you can earn from, as well as creating new contests and sweepstakes too. So check back and I'm sure you will find more and more as we continue to grow. Thank you for commenting and visiting our website.Thank you, William

    • Avatar
      Demetria

      This is a topic that's close to my heart... Cheers! Exactly where are your contact details though?

      • Avatar
        William Williamson
        Apr 10, 2016

        I do apologize for this I will definitely include contact details in my future posts. In most cases I can always be reached by our contact form or emailing support. In many instances if I am not available, which is rarely as I make myself available for customers as much as possible so feel free to contact us at any time.Thank you, William

    • Avatar
      Gilda

      Currently it sounds like Expression Engine is the top blogging platform available right now. (from what I've read) Is that what you are using on your blog?

      • Avatar
        William Williamson
        Apr 10, 2016

        No we are using Prestashop which can be found at www.prestashop.com.Thank you, William

    • Avatar
      Terese

      Very energetic post, I liked that bit. Will there be a part 2?

      • Avatar
        William Williamson
        Apr 10, 2016

        Yes there will be a part two eventually, I am always looking for topics and subjects to write articles on so please if there is a concentration you would like me to cover I will definitely do so.Thank you, William

    • Avatar
      Kristofer

      My coder is trying to convince me to move to .net from PHP. I have always disliked the idea because of the costs. But he's tryiong none the less. I've been using Movable-type on several websites for about a year and am anxious about switching to another platform. I have heard excellent things about blogengine.net. Is there a way I can transfer all my wordpress posts into it? Any help would be greatly appreciated!

      • Avatar
        William Williamson
        Apr 10, 2016

        I believe .NET and PHP are both great when used to fulfill needs or requirements but as with all things there are many pro's and con's, but in general I tend to like PHP more myself. I believe you could transfer your data from one blog to another but you would have to make sure you create or purchase an interface that can take the data from one database and inject it into the new database using the Blog Engine software. Its not always as simple as it sounds but is possible if you want to migrate to a new system.Thank you, William

    • Avatar
      Lavina

      Hi everyone, it's my first pay a quick visit at this web site, and post is in fact fruitful in support of me, keep up posting these types of articles or reviews.

      • Avatar
        William Williamson
        Apr 10, 2016

        Thank you for your visit and thank you for your kind words. We are working on some new content, articles, reviews, and even some contests and sweepstakes. So please keep checking back for updates and more great reading.Thank you, William

    • Avatar
      Marty

      Nice blog! Is your theme custom made or did you download it from somewhere? A theme like yours with a few simple adjustements would really make my blog shine. Please let me know where you got your theme. Bless you

      • Avatar
        William Williamson
        Apr 10, 2016

        Thank you, I am using a free blog which is going to be upgraded soon but its from http://smartdatasoft.com/ and as far as I have seen they are very reputable and professional development site. I hope this helps.Thank you, William

    • Avatar
      Vilma

      Why users still use to read news papers when in this technological world the whole thing is presented on web?

      • Avatar
        William Williamson
        Apr 10, 2016

        I am not sure, but it seems there is always a place for a newspaper on the table for coffee and breakfast. I do agree, though it seems everything is on the internet and can be read with a simple search of www.google.com, www.bing.com, or www.yahoo.com. Thank you for your thoughts.Thank you, William

    • Avatar
      Genia

      Hello, this weekend is pleasant for me, as this time i am reading this enormous informative article here at my house.

      • Avatar
        William Williamson
        Apr 10, 2016

        Thank you, I am glad you are having a pleasant time and I hope you enjoy our articles, tutorials, reviews, and most of all the products you can earn on every time you order them.Thank you, William

    • Avatar
      Dave

      Howdy! I'm at work surfing around your blog from my new iphone! Just wanted to say I love reading your blog and look forward to all your posts!Carry on the outstanding work!

      • Avatar
        William Williamson
        Apr 10, 2016

        Thank you Dave, I am glad you like the website and the content I will be sure to have more great content for you and everyone as soon as possible and keep a look out for some great contents and sweepstakes so you can win while you earn and learn.Thank you, William

    • Avatar
      secretiveflaw2645.blogs.experienceproject.com

      Heya i'm for the primary time here. I found this board and I in finding It really helpful & it helped me out a lot. I'm hoping to provide one thing back and aid others such as you helped me.

      • Avatar
        William Williamson
        Apr 10, 2016

        Thank you I am very glad you found our blog helpful and want to help out as well. I hope you check back and see all the new content coming.

    • Avatar
      local marketing

      hello there and thank you for your info – I have definitely picked up something new from right here. I did however expertise a few technical points using this web site, since I experienced to reload the web site many times previous to I could get it to load correctly. I had been wondering if your hosting is OK? Not that I am complaining, but sluggish loading instances times will often affect your placement in google and could damage your high quality score if ads and marketing with Adwords. Well I'm adding this RSS to my email and could look out for a lot more of your respective fascinating content. Ensure that you update this again soon.

      • Avatar
        William Williamson
        Apr 10, 2016

        Hi, we do apologize for any sluggishness of our server. We do know they have had some issues and I believe all are resolved now in which I am sure you can use our website seamlessly. If not, please write back and let us know. Additionally, we are definitely adding more content and as we do we are beginning to seek out request from readers so please let us know your thoughts on topics you would like to see on our website.Thank you, William

    • Avatar
      Candace

      This website really has all the information I needed concerning this subject and didn't know who to ask.

      • Avatar
        William Williamson
        Apr 10, 2016

        We are so glad to have helped you out. If you ever need any custom work done we know of a new programming and design company called Programmers Direct at www.programmersdirect.com. Now, their website is just getting up so they do not have modules and things to download yet but their custom services are awesome.

    • Avatar
      Local Small Business Marketing Tips

      Hi, all is going nicely here and ofcourse every one is sharing facts, that's actually good, keep up writing.

      • Avatar
        William Williamson
        Apr 10, 2016

        Thank you we are very pleased how much this article has helped everyone.Thank you, William

    • Avatar
      Dwight

      I am regular reader, how are you everybody? This piece of writing posted at this site is truly nice.

      • Avatar
        William Williamson
        Apr 10, 2016

        I am doing fine Dwight. How are you? Thank you we are glad you like the article let us know if we can do anything to improve our website and blog.Thank you, William

    • Avatar
      Cecil

      Fantastic blog! Do you have any suggestions for aspiring writers? I'm planning to start my own blog soon but I'm a little lost on everything. Would you recommend starting with a free platform like Wordpress or go for a paid option? There are so many options out there that I'm totally overwhelmed .. Any tips? Thanks a lot!

      • Avatar
        William Williamson
        Apr 10, 2016

        The best advice I can give is to search blogging on google to get a feel of the do's and don'ts of blogging, which I am still figuring out myself. I would definitely start out with a free software than a paid one as it is less cost and stress to recuperate those costs. Then I would just find topics you are passionate about and write about those topics.Thank you, William

    • Avatar
      Mickie

      It's going to be end of mine day, but before finish I am reading this fantastic piece of writing to improve my know-how.

      • Avatar
        William Williamson
        Apr 10, 2016

        Thank you, we are glad you stopped by and read our article. do not forget to browse our huge list of products that you earn money back from buying.Thank you, William

    • Avatar
      Samantha

      I was just looking at your Make Checkboxes in Prestashop Using helpers website and see that your website has the potential to get a lot of visitors. I just want to tell you, In case you don't already know... There is a website network which already has more than 16 million users, and most of the users are looking for topics like yours. By getting your website on this service you have a chance to get your site more visitors than you can imagine. It is free to sign up and you can read more about it here: http://todochiapas.mx/C/3jq - Now, let me ask you... Do you need your site to be successful to maintain your business? Do you need targeted visitors who are interested in the services and products you offer? Are looking for exposure, to increase sales, and to quickly develop awareness for your site? If your answer is YES, you can achieve these things only if you get your site on the service I am talking about. This traffic network advertises you to thousands, while also giving you a chance to test the network before paying anything. All the popular sites are using this service to boost their traffic and ad revenue! Why aren’t you? And what is better than traffic? It’s recurring traffic! That's how running a successful site works... Here's to your success! Find out more here: http://url.laspas.gr/ak

      • Avatar
        William Williamson
        Apr 10, 2016

        Wow, thank you for the compliment, advice, and referral.Thank you, William

    • Avatar
      The Latest Hultquist Jewellery Collection

      Learn how to make a ravishing beaded eyeglass leash that additionally could be worn as a necklace.

      • Avatar
        William Williamson
        Apr 10, 2016

        Thank you for your comment.

    • Avatar
      Lukas

      Your blog can go viral, you need some initial traffic only.How to get initial traffic?? Search in google for: nhuum's tips

      • Avatar
        William Williamson
        Apr 10, 2016

        Thank you for the tips and advice.Thank you, William

    • Avatar
      MaySandridge

      I see, that http://www.shopsavenearn.com needs unique & fresh articles. I know it's hard to write articles manually everyday, but there is solution for this. Simply search in google for: Imcad's Essential Tool

      • Avatar
        William Williamson
        Apr 10, 2016

        Thank you for your accurate observation, which I am fixing asap in which we are releasing more articles than ever so please check back for more up to date content and articles.Thank you for the advice as well we will surly check out your advice.Thank you, William

    • Avatar
      Cristina

      Despite being pure, quite a few companies specialize in this sort of outfits to offer brides an eco-nice but fashionable and delightful marriage ceremony gowns. I do not put on much make-up, but she's the kind of woman who won't depart the home with out her face on. Crinkled materials are normally used for such skirts, stuffed with numbers to suit software. With our fabulous supply, it can save you pounds on vintage-type tops, tweed trousers and cosy faux fur-trimmed jackets.

      • Avatar
        William Williamson
        Apr 10, 2016

        Thank you for your comment.Thank you, William

    • Avatar
      coco service fiverr

      1fE8Ow Pretty! This was an extremely wonderful article. Thank you for supplying these details.

      • Avatar
        William Williamson
        Apr 10, 2016

        Thank you for your compliments, we strive to bring you great and informative articles.Thank you, William

Leave a Reply

* Name:
* E-mail: (Not Published)
   Website: (Site url withhttp://)
* Comment:
Type Code