[Skip to main content](#vessel-content)

Board Categories Development HikaShop 3.0 Beta

##

#  [Development](/forum/31-development "View Category 'Development'")  582 topics

| If you are developping a plugin for Hikashop or customizing our component, this is the board to be. |
|---|
|  | Category | Last Post |
| [ ](/forum/57-hikashop-3-0-beta) | ###  [HikaShop 3.0 Beta](/forum/57-hikashop-3-0-beta "View Category 'HikaShop 3.0 Beta'")  42 topics  [  ](/forum/57-hikashop-3-0-beta/feed?format=feed&type=rss) | [Re: Quantity Bundled Products](/forum/57-hikashop-3-0-beta/891293-quantity-bundled-products#336351 "Hi,  Yes. It was added in the 3.4.0 3 years ago:   www.hikashop.com/support/documentation/5...ashop-changelog.html")     by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")     5 years 3 weeks ago |

##

| <a id="forumtop"> </a> [  ](#forumbottom) | Subject | Replies / Views | Last Post |
|---|---|---|---|
| [](/forum/31-development/905880-create-a-custom-type-of-filter-based-on-the-checkbox) | [Create a custom type of filter based on the checkbox](/forum/31-development/905880-create-a-custom-type-of-filter-based-on-the-checkbox "Hi,  I am trying to create a custom filter type. This would be a copy of the 'checkbox' filter with some differences in the display (hidden option values by default, unless you click on the 'category').  I don't know if it's possible, but I had started to try by following the documentation that explains how to use the overrides. I've made some progress (creating the filter with this new type in the backend seems ok) and I have created these files : &#92;administrator&#92;templates&#92;atum&#92;html&#92;com&#95;hikashop&#92;administrator&#92;classes&#92;filter.override.php &#92;administrator&#92;templates&#92;atum&#92;html&#92;com&#95;hikashop&#92;administrator&#92;types&#92;filter.override.php  My question is about the override in the 'classes' folder: I have tried these classes without result: class hikashopFilterClassOverride extends hikashopClass { class hikashopFilterClassOverride extends hikashopFilterClass {  1) I understand that the 'displayFilter()' function is used, but is it possible to override it? Because whatever I do, I pass in the function defined here: (~l.382) &#92;administrator&#92;components&#92;com&#95;hikashop&#92;classes&#92;filter.php  Other question: In this file, we have the code (~l.384):  2) Is there a way to call a class defined in the '&#92;classes&#92;filter.override.php' file ? At the end I had tried to define/override these classes unsuccessfully: class hikashopFilterClassOverride extends hikashopClass { class hikashopRadiocustomClass extends hikashopFilterClass{ class hikashopCheckboxcustomClass extends hikashopRadiocustomClass{  Thanks in advance for your answer.")        Category: [Development](/forum/31-development "If you are developping a plugin for Hikashop or customizing our component, this is the board to be.")     Topic started 3 years 9 months ago, by [FDBI](/forum/user/63027-fdbi "View FDBI's Profile")       [Last Post](/forum/31-development/905880-create-a-custom-type-of-filter-based-on-the-checkbox#349551 "Hi,  With this latest version the problem seems to be gone.  Thank you !") 3 years 8 months ago     by [FDBI](/forum/user/63027-fdbi "View FDBI's Profile") | Replies:14  Views:1146 | [Last Post](/forum/31-development/905880-create-a-custom-type-of-filter-based-on-the-checkbox#349551 "Hi,  With this latest version the problem seems to be gone.  Thank you !") by [FDBI](/forum/user/63027-fdbi "View FDBI's Profile")      3 years 8 months ago |
| [](/forum/31-development/905848-supported-versions-and-router) | [Supported versions and Router](/forum/31-development/905848-supported-versions-and-router "-- HikaShop version -- : 4.7.1 -- Joomla version -- : 4.2.7 -- PHP version -- : 7.4  Hello, I'm currently creating a better finder plugin for hikashop and I'm running into serious issues with the router. The URLs are simply completely wrong, which is mainly due to the Itemid being hardcoded to the URL. When I look at the router, I also see issues there and it would start with unnecessarily complex code there. The question would be, which Joomla versions you are supporting, because unless you are support Joomla from before 3.6, you could drop half the code in your router.  To be specific:  could be replaced with  Where ... is the actual program code. That code would be working from Joomla 3.6 onwards.  Besides that, it would be nice if the router would discover the Itemid dynamically similar to how the core does it. That means that you don't have to store the Itemid in the finder and if you change your sites structure, move a category to a different place or something similar, your URLs would still be correct.  If you are interested in a rewrite of either the router or the finder plugin, feel free to contact me.")        Category: [Development](/forum/31-development "If you are developping a plugin for Hikashop or customizing our component, this is the board to be.")     Topic started 3 years 9 months ago, by [hackwar](/forum/user/35377-hackwar "View hackwar's Profile")       [Last Post](/forum/31-development/905848-supported-versions-and-router#349037 "The goal is, that the router itself can dig up the right data it needs. In worst case, you could find out everything just by having the product ID. Joomla hands in everything else just to improve...") 3 years 9 months ago     by [hackwar](/forum/user/35377-hackwar "View hackwar's Profile") | Replies:2  Views:1020 | [Last Post](/forum/31-development/905848-supported-versions-and-router#349037 "The goal is, that the router itself can dig up the right data it needs. In worst case, you could find out everything just by having the product ID. Joomla hands in everything else just to improve...") by [hackwar](/forum/user/35377-hackwar "View hackwar's Profile")      3 years 9 months ago |
| [](/forum/31-development/905818-custom-field-to-generate-random-number) | [Custom field to generate random number](/forum/31-development/905818-custom-field-to-generate-random-number "-- HikaShop version -- : 4.5.0 -- Joomla version -- : 4.1.5 -- PHP version -- : 7.4.33  Hi guys,  i need to set up a custom field which would generate random 4 numbers which i'd later show in the invoice. I'd set it up in the Order table but the question is, is it possible to use the custom text field type to use php code which will generate the random number for me or there's another way to do it?  cheers")        Category: [Development](/forum/31-development "If you are developping a plugin for Hikashop or customizing our component, this is the board to be.")     Topic started 3 years 9 months ago, by [jberry210490](/forum/user/6511-jberry210490 "View jberry210490's Profile")       [Last Post](/forum/31-development/905818-custom-field-to-generate-random-number#348866 "Hi,  You can create a mass action with a trigger &quot;after an order is created&quot; with an action &quot;update the values&quot; on the column of your custom field with the mode &quot;operation&quot; and some MySQL commands to generate the number. Several propositions are presented here:   stackoverflow.com/questions/3964624/how-...igit-number-in-mysql  I suppose I would try something like that:  Otherwise, if you update your HikaShop, you'll have the &quot;run PHP code&quot; action in mass actions, and you can do it with PHP code like this: where xxx is the column of your custom field.") 3 years 9 months ago     by [nicolas](/forum/user/63-nicolas "View nicolas's Profile") | Replies:1  Views:1302 | [Last Post](/forum/31-development/905818-custom-field-to-generate-random-number#348866 "Hi,  You can create a mass action with a trigger &quot;after an order is created&quot; with an action &quot;update the values&quot; on the column of your custom field with the mode &quot;operation&quot; and some MySQL commands to generate the number. Several propositions are presented here:   stackoverflow.com/questions/3964624/how-...igit-number-in-mysql  I suppose I would try something like that:  Otherwise, if you update your HikaShop, you'll have the &quot;run PHP code&quot; action in mass actions, and you can do it with PHP code like this: where xxx is the column of your custom field.") by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")      3 years 9 months ago |
| [](/forum/31-development/905612-custom-email-header) | [Custom Email Header](/forum/31-development/905612-custom-email-header "-- HikaShop version -- : 4.7 -- Joomla version -- : 4.2.3 -- PHP version -- : 8.1.11  I commonly include a custom email header in emails sent via Joomla's Mail class (e.g.: &quot;x-customname: sample;&quot;, which are added by using PhpMailer's -&gt;AddCustomHeader method on Joomla's Mail class, which extends PhpMailer). I'd like to include a similar header in Hikashop's generated emails, mostly to help me use rules to sort my incoming mail, but partly to do things like identifying which of HikaShop's templates was used or including custom data from custom plugins I occasionally write.  I know I could modify HikaShop's mail object, but is there some kind of override method or plugin process that wouldn't be overridden by updates?  Could you add this as a possible feature to include in a future update?")        Category: [Development](/forum/31-development "If you are developping a plugin for Hikashop or customizing our component, this is the board to be.")     Topic started 3 years 10 months ago, by [MonkeyT12](/forum/user/69401-monkeyt12 "View MonkeyT12's Profile")       [Last Post](/forum/31-development/905612-custom-email-header#348058 "Thanks. I didn't know if the $data value provided to the plugin was an actual Mail object or just a structure holding the requisite data.") 3 years 10 months ago     by [MonkeyT12](/forum/user/69401-monkeyt12 "View MonkeyT12's Profile") | Replies:2  Views:901 | [Last Post](/forum/31-development/905612-custom-email-header#348058 "Thanks. I didn't know if the $data value provided to the plugin was an actual Mail object or just a structure holding the requisite data.") by [MonkeyT12](/forum/user/69401-monkeyt12 "View MonkeyT12's Profile")      3 years 10 months ago |
| [](/forum/31-development/905611-onbeforedownloadfile) | [onBeforeDownloadFile](/forum/31-development/905611-onbeforedownloadfile "-- HikaShop version -- : 4.7.0 -- Joomla version -- : 4.latest -- PHP version -- : 8.1  Hello, I thought I was finished...  I have made a plugin that adds customer-specific information to the pdf of an E-book, and then makes it available for download. I am using onBeforeDownloadFile.  It works perfect for 1 pdf....but I have hit a small problem if the customer orders multiple downloadable products.  When hikashop executes onBeforeDownloadFile(&amp;$filename, &amp;$do, &amp;$file, $options) how can I obtain the information which download button was clicked?  Suppose that the customer has purchased 10 downloadable products, and is now in the download page. There are 10 buttons to click on for download. Click on button 1, and my plugin adjusts all 10 pdf files.....but unfortunately always shows the first one.  I can get the order ID from: $order&#95;id = $file-&gt;order&#95;id;  I can get the entire order and user information from:  $app = JFactory::getApplication(); $orderClass = hikashop&#95;get('class.order'); $FullOrder = $orderClass-&gt;loadFullOrder($order&#95;id, true, false);  From that I can get for example the invoice number: $InvNum = $FullOrder-&gt;order&#95;invoice&#95;number;  But how do I know which title (product ID) the customer wants to download?  Something like this will only iterate through all products. foreach($FullOrder-&gt;products as $product) { $ProductID = $product-&gt;order&#95;product&#95;code;  //adjust filename  }  I need to know which download product the customer just clicked on. So that I only have to adjust that specific pdf, and only show that specific pdf.  I guess the answer must be somewhere in your downloads.php. Kind regards,  Alain")        Category: [Development](/forum/31-development "If you are developping a plugin for Hikashop or customizing our component, this is the board to be.")     Topic started 3 years 10 months ago, by [highstat@highstat.com](/forum/user/70596-highstat-highstat-com "View highstat@highstat.com's Profile")       [Last Post](/forum/31-development/905611-onbeforedownloadfile#347869 "Hi,  In $file-&gt;file&#95;ref&#95;id you have the id of the product. You also have it in your loop in $product-&gt;product&#95;id. So you can compare both to make sure you're using the code of the correct product.") 3 years 10 months ago     by [nicolas](/forum/user/63-nicolas "View nicolas's Profile") | Replies:2  Views:900 | [Last Post](/forum/31-development/905611-onbeforedownloadfile#347869 "Hi,  In $file-&gt;file&#95;ref&#95;id you have the id of the product. You also have it in your loop in $product-&gt;product&#95;id. So you can compare both to make sure you're using the code of the correct product.") by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")      3 years 10 months ago |
| [](/forum/31-development/905532-user-specific-downloads) | [user-specific downloads](/forum/31-development/905532-user-specific-downloads "-- Joomla version -- : 4.latest -- PHP version -- : 8.1  Hello, I sell books and e-books. I managed to write a Hikashop plugin that adds user-specific information in the header of each page of the pdf (social DRM) of an e-book. It all works nice..thanks to your help in other posts.  The last problem is delivery to the customer. The source file is called book1.pdf (for example) and is in a safe place. After the user-specific information has been added, it is called book1InvoiceNumber.pdf....where InvoiceNumber is derived from $order. I have 10 of these books; some are 5 Mb....some are 100 Mb....so emailing them as an attachment is not an option.  The easiest option to get the adjusted pdf to the customer is to automatically save it in the 'safe' directory, and email the link to the customer. And once in a while clean it up manually. That falls within my technical abilities. By 'safe' I mean out of sight of people who are trying to guess the path to a directory.  The fanciest option would be to use the download options from Hikashop. That is...add the source pdf to the Product -Images and Files, and once the order is confirmed, let Hikashop email the customer with the download link and also the options to limit the number of downloads and the download time. Problem: Currently, Hikashop does not know that the pdf link has changed to a user-specific pdf file. Is it possible to change the link to the pdf file in the user confirmation email, and also on the user-download section? Or formulated differently....is it difficult to do this?  Alain")        Category: [Development](/forum/31-development "If you are developping a plugin for Hikashop or customizing our component, this is the board to be.")     Topic started 3 years 11 months ago, by [highstat@highstat.com](/forum/user/70596-highstat-highstat-com "View highstat@highstat.com's Profile")       [Last Post](/forum/31-development/905532-user-specific-downloads#347492 "Hi,  1. The $filename seems good in your code.  2. It needs to be the full path, like in your code.  3. Yes  4. No. That's the whole point. If you remove the htaccess then anyone could potentially access the files in the folder by directly entering the correct path in his browser.  5. Yes, the file name can be different, as long as it exists.  6. You simply get that error because of the line:  which cancels the file download. In your case, you don't want to change $do in your plugin.") 3 years 10 months ago     by [nicolas](/forum/user/63-nicolas "View nicolas's Profile") | Replies:3  Views:949 | [Last Post](/forum/31-development/905532-user-specific-downloads#347492 "Hi,  1. The $filename seems good in your code.  2. It needs to be the full path, like in your code.  3. Yes  4. No. That's the whole point. If you remove the htaccess then anyone could potentially access the files in the folder by directly entering the correct path in his browser.  5. Yes, the file name can be different, as long as it exists.  6. You simply get that error because of the line:  which cancels the file download. In your case, you don't want to change $do in your plugin.") by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")      3 years 10 months ago |
| [](/forum/31-development/905522-plugin) | [plugin](/forum/31-development/905522-plugin "-- Joomla version -- : 4.latest -- PHP version -- : 8.1  Hello,  I am writing a plugin that does the following upon successful payment:  1. Get the invoice number and email address of the customer. 2. Inspect the products that were ordered. 3. If products A, B and C were ordered (these are E-books), then add his/her email address to each page of an existing pdf file (E-book). And save the pdf. 4. Email the customer with a download link for the newly created pdf.  I am not an expert in php, but I know how to google. Step 3, I managed to program using the Setas package. Step 4 ... I still need to think about how to do this. As to steps 1 and 2.....I spent most of this day on your manual and Forums. I came up with the php code below. It seems to work ok.  My question is: Is this a valid way to obtain the invoice number and email address of the customer, and the products that were ordered? I am slightly confused why $cart = $cartClass-&gt;getFullCart(); is linked to the current order. Why can't you take the ordered products from the $order object? Would that not be better?  Alain  And this is the xml file")        Category: [Development](/forum/31-development "If you are developping a plugin for Hikashop or customizing our component, this is the board to be.")     Topic started 3 years 11 months ago, by [highstat@highstat.com](/forum/user/70596-highstat-highstat-com "View highstat@highstat.com's Profile")       [Last Post](/forum/31-development/905522-plugin#347462 "Thank you very much. That seems to all work fine!  Alain") 3 years 11 months ago     by [highstat@highstat.com](/forum/user/70596-highstat-highstat-com "View highstat@highstat.com's Profile") | Replies:4  Views:980 | [Last Post](/forum/31-development/905522-plugin#347462 "Thank you very much. That seems to all work fine!  Alain") by [highstat@highstat.com](/forum/user/70596-highstat-highstat-com "View highstat@highstat.com's Profile")      3 years 11 months ago |
| [](/forum/31-development/885467-add-product-to-cart-using-a-plugin) | [Add product to cart using a plugin](/forum/31-development/885467-add-product-to-cart-using-a-plugin "-- HikaShop version -- : 2.6.3 -- Joomla version -- : 3.5.1 -- PHP version -- : 7.0.9 -- Browser(s) name and version -- : FF  Because Hikashop doesn't provide a functionality to add a product for free when a certain cart amount is met, I'm trying to build a plugin who does that for me. Could you provide a code sample how to add a product to the cart when a plugin event is fired? can I also then reset the the price to 0?  Hope you can get me started...")        Category: [Development](/forum/31-development "If you are developping a plugin for Hikashop or customizing our component, this is the board to be.")     Topic started 10 years 4 months ago, by [Rixters](/forum/user/28762-rixters "View Rixters's Profile")       [Last Post](/forum/31-development/885467-add-product-to-cart-using-a-plugin#346549 "Hi,  Where do you want to do that ? What information of the products you have at hand ?") 3 years 11 months ago     by [nicolas](/forum/user/63-nicolas "View nicolas's Profile") | Replies:10  Views:3057 | [Last Post](/forum/31-development/885467-add-product-to-cart-using-a-plugin#346549 "Hi,  Where do you want to do that ? What information of the products you have at hand ?") by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")      3 years 11 months ago |
| [](/forum/31-development/905151-get-cart-class-in-ajax-function) | [Get cart class in Ajax function](/forum/31-development/905151-get-cart-class-in-ajax-function "-- url of the page with the problem -- :   eduquay.satumalaysiahosting.com/booklist  Hi there,  I am facing an error which I unable to get cart class in my ajax function. (Previously worked BTW)  The attachments below are my ajax function and product listing.")         Category: [Development](/forum/31-development "If you are developping a plugin for Hikashop or customizing our component, this is the board to be.")     Topic started 4 years 1 month ago, by [JF](/forum/user/67343-jf "View JF's Profile")       [Last Post](/forum/31-development/905151-get-cart-class-in-ajax-function#345633 "Its worked, thanks!!!") 4 years 1 month ago     by [JF](/forum/user/67343-jf "View JF's Profile") | Replies:2  Views:903 | [Last Post](/forum/31-development/905151-get-cart-class-in-ajax-function#345633 "Its worked, thanks!!!") by [JF](/forum/user/67343-jf "View JF's Profile")      4 years 1 month ago |
| [](/forum/31-development/902924-override-function-in-helper-php) | [Override function in helper.php](/forum/31-development/902924-override-function-in-helper-php "-- HikaShop version -- : 4.4.3 -- Joomla version -- : 3.9.28 -- PHP version -- : 7.4.20 -- Browser(s) name and version -- : all  Hi,  I have a question how to correctly override function in /administrator/components/com&#95;hikashop/helpers/helper.php? I need to change a little the generation of order number in hikashop&#95;encode function. I know how to override some class in helpers (eg image.php) but don't know how to do it with this helper functions.  Thanks, Jan")        Category: [Development](/forum/31-development "If you are developping a plugin for Hikashop or customizing our component, this is the board to be.")     Topic started 5 years 4 months ago, by [braverman](/forum/user/30455-braverman "View braverman's Profile")       [Last Post](/forum/31-development/902924-override-function-in-helper-php#344601 "Hi,  Joomla is based on the MVC model (   en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller  ). And HikaShop too. So in HikaShop's folder, you'll find &quot;classes&quot; which is for the models, &quot;controllers&quot;, for the controllers and &quot;views&quot; for the views. The &quot;helpers&quot; folder contains files with helpers that can be used by the MVC elements which aren't tied to one view, one controller or one model. For example the &quot;translation&quot; helper has functions that are used by the views and controllers to manage the translations of the content.") 4 years 2 months ago     by [nicolas](/forum/user/63-nicolas "View nicolas's Profile") | Replies:5  Views:1428 | [Last Post](/forum/31-development/902924-override-function-in-helper-php#344601 "Hi,  Joomla is based on the MVC model (   en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller  ). And HikaShop too. So in HikaShop's folder, you'll find &quot;classes&quot; which is for the models, &quot;controllers&quot;, for the controllers and &quot;views&quot; for the views. The &quot;helpers&quot; folder contains files with helpers that can be used by the MVC elements which aren't tied to one view, one controller or one model. For example the &quot;translation&quot; helper has functions that are used by the views and controllers to manage the translations of the content.") by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")      4 years 2 months ago |
| [](/forum/31-development/904956-joomla-4-override-not-working) | [Joomla 4 - override not working](/forum/31-development/904956-joomla-4-override-not-working "-- HikaShop version -- : 4.6.1 -- Joomla version -- : 4.2.2  Hi, I'm trying to do a Joomla 4 override but it's not working. I tested on Jooma 3 works without problems. I did it this way: YOUR&#95;FRONT&#95;END&#95;TEMPLATE/html/com&#95;hikashop/administrator/helpers/dropdown.override.php")        Category: [Development](/forum/31-development "If you are developping a plugin for Hikashop or customizing our component, this is the board to be.")     Topic started 4 years 2 months ago, by [neo191987](/forum/user/35364-neo191987 "View neo191987's Profile")       [Last Post](/forum/31-development/904956-joomla-4-override-not-working#344424 "Hi,  Good idea. I checked the code of HikaSerial, HikaAuction and HikaMarket. Only HikaSerial has the same issue. So we'll have to modify this for the next version of HikaSerial.") 4 years 2 months ago     by [nicolas](/forum/user/63-nicolas "View nicolas's Profile") | Replies:6  Views:1352 | [Last Post](/forum/31-development/904956-joomla-4-override-not-working#344424 "Hi,  Good idea. I checked the code of HikaSerial, HikaAuction and HikaMarket. Only HikaSerial has the same issue. So we'll have to modify this for the next version of HikaSerial.") by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")      4 years 2 months ago |
| [](/forum/31-development/904886-how-to-get-all-products-from-category-php) | [How to get all products from category (PHP)](/forum/31-development/904886-how-to-get-all-products-from-category-php "-- HikaShop version -- : 4.6.1 -- Joomla version -- : 4.x -- PHP version -- : 8.0  I'm working on an integration to YOOtheme Pro. Currently on the category with products listing. I wonder if a function exists to get all products of a given category, like how we can get a product with:  Or do I need to get them manually using a mysql query?  Thanks")        Category: [Development](/forum/31-development "If you are developping a plugin for Hikashop or customizing our component, this is the board to be.")     Topic started 4 years 2 months ago, by [dyvel](/forum/user/39996-dyvel "View dyvel's Profile")       [Last Post](/forum/31-development/904886-how-to-get-all-products-from-category-php#344080 "Hi,  There is no function for that. You have the function getProductsIn in class.category which is quite close to what you need. But you would need to remove the $products parameter and the code using it. I think this function is a good base even if you just want to get the MySQL query.") 4 years 2 months ago     by [nicolas](/forum/user/63-nicolas "View nicolas's Profile") | Replies:2  Views:9726 | [Last Post](/forum/31-development/904886-how-to-get-all-products-from-category-php#344080 "Hi,  There is no function for that. You have the function getProductsIn in class.category which is quite close to what you need. But you would need to remove the $products parameter and the code using it. I think this function is a good base even if you just want to get the MySQL query.") by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")      4 years 2 months ago |
| [](/forum/31-development/904833-onafterorderupdate-not-show-cart-object) | [onAfterOrderUpdate not show Cart object](/forum/31-development/904833-onafterorderupdate-not-show-cart-object "-- HikaShop version -- : 4.4.5  hi i have two different site with hikashop and i write some code in history plugin . in one of that it is work and in other it is not work. when i dump for show all inside $order the first(hika 4.4.2) return Cart and the second(hika4.4.5) not return Cart. look at picture.")         Category: [Development](/forum/31-development "If you are developping a plugin for Hikashop or customizing our component, this is the board to be.")     Topic started 4 years 3 months ago, by [sadaf3d](/forum/user/46256-sadaf3d "View sadaf3d's Profile")       [Last Post](/forum/31-development/904833-onafterorderupdate-not-show-cart-object#343815 "Hi,  Like all the &quot;update&quot; events, the onAfterOrderUpdate's first parameter contains the data being saved in the database. This depends on what the code calling the class.order's save method provided. To update an order the minimum required is to provide the order&#95;id. For example:  This will provide to the onAfterOrderUpdate event with an object with 4 things: - the old attribute which contains an object of the order data in the database before the data in the database was updated - the history attribute, which contains a history object with generic information going into the &quot;history&quot; table for that order - the order&#95;id that the code set in $order to target the corresponding order - the order&#95;modified which contains the current unix timestamp to be saved in the database That's the only things you'll always have in that first parameter of onAfterOrderUpdate. Anything else is added or not by the code calling the save function and as a plugin implementing the event you have no guarantee that they will be provided.  The &quot;cart&quot; attribute might be available when an order is updated in the same thread as it's being created, or it might be set by the email system when the email tags are being generated. You can rely on that attribute being always present in the first parameter of the event. If it's added by the emails and you disable the emails in System&gt;Emails, then the cart attribute wouldn't be provided for example. And if you run a mass action to update orders, the emails won't be sent and that attribute won't be there either.  Note however that the cart attribute is just the data returned by loadFullOrder So you could just have that code at the beginning of your code:") 4 years 3 months ago     by [nicolas](/forum/user/63-nicolas "View nicolas's Profile") | Replies:1  Views:908 | [Last Post](/forum/31-development/904833-onafterorderupdate-not-show-cart-object#343815 "Hi,  Like all the &quot;update&quot; events, the onAfterOrderUpdate's first parameter contains the data being saved in the database. This depends on what the code calling the class.order's save method provided. To update an order the minimum required is to provide the order&#95;id. For example:  This will provide to the onAfterOrderUpdate event with an object with 4 things: - the old attribute which contains an object of the order data in the database before the data in the database was updated - the history attribute, which contains a history object with generic information going into the &quot;history&quot; table for that order - the order&#95;id that the code set in $order to target the corresponding order - the order&#95;modified which contains the current unix timestamp to be saved in the database That's the only things you'll always have in that first parameter of onAfterOrderUpdate. Anything else is added or not by the code calling the save function and as a plugin implementing the event you have no guarantee that they will be provided.  The &quot;cart&quot; attribute might be available when an order is updated in the same thread as it's being created, or it might be set by the email system when the email tags are being generated. You can rely on that attribute being always present in the first parameter of the event. If it's added by the emails and you disable the emails in System&gt;Emails, then the cart attribute wouldn't be provided for example. And if you run a mass action to update orders, the emails won't be sent and that attribute won't be there either.  Note however that the cart attribute is just the data returned by loadFullOrder So you could just have that code at the beginning of your code:") by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")      4 years 3 months ago |
| [](/forum/31-development/904794-obtain-product-object-in-onbeforecalculateproductpriceforquantity-event-handler) | [Obtain product object in onBeforeCalculateProductPriceForQuantity event handler](/forum/31-development/904794-obtain-product-object-in-onbeforecalculateproductpriceforquantity-event-handler "-- HikaShop version -- : 4.6.1 -- Joomla version -- : 4.1.5 -- PHP version -- : 8.0 -- Browser(s) name and version -- : FireFox 100.0.2 (64-bit) -- Error-message(debug-mod must be tuned on) -- : trim(): Argument #1 ($string) must be of type string, array given  Hi Nicolas,  Before explaining the problem I encounter, let me first explain what I am trying to do.  In the onBeforeCalculateProductPriceForQuantity() event handler of a system plugin, I try to construct a product object, including all related information. I need such an object, including any associated custom fields and other data, to do some non standard price calculations. The way I try to obtain that product object is as follows:  &#42; Get a reference to the product class: $productClass = hikashop&#95;get('class.product')  &#42; Load the product using the product&#95;id in the method parameter: $productClass-&gt;getProducts(&#91;$product-&gt;product&#95;id&#93;)  &#42; Load additional product data using the now available product(s) in $productClass: $productClass-&gt;loadProductsListingData(&#91;$productClass-&gt;products&#91;(string) $product-&gt;product&#95;id&#93;&#93;, )  &#42; Load product options in a similar fashion: $productClass-&gt;loadProductOptions((&#91;$productClass-&gt;products&#91;(string) $product-&gt;product&#95;id&#93;&#93;)  I feel very uncomfortable with the way I managed to get what I need, but in the old, complicated and confusing, non-modular codebase that is HikaShop is, I saw no other way. It gave me the product object I need though and everything seems to work just fine, up to the point that I go to the checkout page and change the ordered amount of a product. This also triggers my onBeforeCalculateProductPriceForQuantity() method, which should be fine, but apparently isn't. This is what I see happening:  &#42; When changing the product quantity, an AJAX call is made which eventually calls hikashopCartClass::loadFieldsForProducts(), which in turn calls hikashopFieldClass::getData().  &#42; That getData() method fills a static variable with product data. Items in that data collection contain an attribute field&#95;categories, which contains a comma separated string of category id's.  &#42; Somewhat later, my onBeforeCalculateProductPriceForQuantity() event handler is called.  &#42; The call I make to hikashopProductClass::loadProductsListingData() (see 2. above) in turn calls hikashopProductClass::loadCustomItemFieldsForProductsListing().  That last function call is where the problem starts. For some reason, it turns the comma separated string of category id's mentioned above into an array. Then, when hikashopCartClass::loadFieldsForProducts() is called a second time around as part of the same AJAX call, an error occurs because an attempt is made to trim() an array, which obviously is not allowed. This results in the following message in the shopping cart area: trim(): Argument #1 ($string) must be of type string, array given.  What must I do to resolve this?")        Category: [Development](/forum/31-development "If you are developping a plugin for Hikashop or customizing our component, this is the board to be.")     Topic started 4 years 3 months ago, by [pjdevries](/forum/user/64503-pjdevries "View pjdevries's Profile")       [Last Post](/forum/31-development/904794-obtain-product-object-in-onbeforecalculateproductpriceforquantity-event-handler#343592 "Hi Nicolas,  Thanx for your reply and proposed solution. It seems to work, but just a bit different. Because all my code, following the hikashopProductClass::loadProductsListingData() call, currently relies on the categories attribute being an array, I call the reset not before but after loadProductsListingData(). That way, both my code and the core HikaShop code keeps working, hopefully. Please make sure to document any changes you make to this logic, so we keep an eye on it before updating without consideration.  As for improving the HikaShop code base, I suggest you start working towards a cleaner, better maintainable and less complex code base. Get rid of (most) statics and of data passed and manipulated by reference. In many cases, for arrays and objects, a reference it is not even necessary. Refactor all your classes, starting with a well designed Product class, which should be and do more than be a Product :) Turn factory methods, that currently manipulate static objects or objects passed by reference, into methods that return properly typed objects. For instance, turn hikashopFieldClass::getData() into something like ProductFactory::createProduct(), which returns an object of type (class) Product. Keep things simple. Do not create methods of several hundreds, sometimes 1000 or more lines of code. Keep the SOLID principles in the back of your head (  en.wikipedia.org/wiki/SOLID ).  I think cleaning up your code base is very important, because PHP is getting more critical and less forgiving with every new release. I'm afraid HikaShop will crash completely by the time we reach PHP 9.") 4 years 3 months ago     by [pjdevries](/forum/user/64503-pjdevries "View pjdevries's Profile") | Replies:2  Views:1119 | [Last Post](/forum/31-development/904794-obtain-product-object-in-onbeforecalculateproductpriceforquantity-event-handler#343592 "Hi Nicolas,  Thanx for your reply and proposed solution. It seems to work, but just a bit different. Because all my code, following the hikashopProductClass::loadProductsListingData() call, currently relies on the categories attribute being an array, I call the reset not before but after loadProductsListingData(). That way, both my code and the core HikaShop code keeps working, hopefully. Please make sure to document any changes you make to this logic, so we keep an eye on it before updating without consideration.  As for improving the HikaShop code base, I suggest you start working towards a cleaner, better maintainable and less complex code base. Get rid of (most) statics and of data passed and manipulated by reference. In many cases, for arrays and objects, a reference it is not even necessary. Refactor all your classes, starting with a well designed Product class, which should be and do more than be a Product :) Turn factory methods, that currently manipulate static objects or objects passed by reference, into methods that return properly typed objects. For instance, turn hikashopFieldClass::getData() into something like ProductFactory::createProduct(), which returns an object of type (class) Product. Keep things simple. Do not create methods of several hundreds, sometimes 1000 or more lines of code. Keep the SOLID principles in the back of your head (  en.wikipedia.org/wiki/SOLID ).  I think cleaning up your code base is very important, because PHP is getting more critical and less forgiving with every new release. I'm afraid HikaShop will crash completely by the time we reach PHP 9.") by [pjdevries](/forum/user/64503-pjdevries "View pjdevries's Profile")      4 years 3 months ago |
| [](/forum/31-development/904771-manual-redirect-weirdness) | [Manual Redirect Weirdness](/forum/31-development/904771-manual-redirect-weirdness "-- HikaShop version -- : 4.6.0 -- Joomla version -- : 4.1.5 -- PHP version -- : 7.4.30  I have a strange one.  To simplify the User Registration Forms, I am using Layout Template overrides. We are using a large set of User custom fields as a User Profile which are only needed for a small set of Joomla Users, but are rarely needed for Store Customers - we can't make them &quot;required&quot; so we modified the Registration templates.  All of that is working fine, both through registrations via purchases and the online registration form (HikaShop's form, not Joomla's).  If a registered Joomla User accidentally visits the Registration page, I want to redirect them to the custom &quot;Welcome&quot; article we built. Using Joomla's access control on the Menu item gives us the benefit of hiding our menu's &quot;Create Account&quot; link from registered visitors, but it redirects a User back to the Home page, along with an error message we'd rather customize. I don't think there's a way to customize that built-in redirect, so I'd rather handle redirection on the Registration page itself.  This sounds simple: just add an application-&gt;redirect() after checking the User's Guest property. The problem is that for some unknown reason, my test-driven redirect's address value gets overridden by one which sends the browser to HikaShop's Customer Dashboard page - which we don't even run an instance of. (the redirected url becomes &quot;/component/hikashop/user/cpanel&quot;)  I have no idea where to even look for this problem. Suggestions?  Thanks.")        Category: [Development](/forum/31-development "If you are developping a plugin for Hikashop or customizing our component, this is the board to be.")     Topic started 4 years 3 months ago, by [icomex](/forum/user/4967-icomex "View icomex's Profile")       [Last Post](/forum/31-development/904771-manual-redirect-weirdness#343524 "Hi,  Yes, thank you for your feedback. We'll add this as a hidden option.") 4 years 3 months ago     by [nicolas](/forum/user/63-nicolas "View nicolas's Profile") | Replies:3  Views:951 | [Last Post](/forum/31-development/904771-manual-redirect-weirdness#343524 "Hi,  Yes, thank you for your feedback. We'll add this as a hidden option.") by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")      4 years 3 months ago |
| [](/forum/31-development/904723-error-messages-using-ajax-addtocart) | [Error messages using AJAX AddToCart](/forum/31-development/904723-error-messages-using-ajax-addtocart "-- HikaShop version -- : 4.6.1 -- Joomla version -- : 3.10.10 -- PHP version -- : 7.4.30  I have a HikaShop plugin written years ago to prevent Customers in a specific User group from adding a particular item to their cart if they don't have meet specific requirements, which has quietly worked for years (These customers are partners of the site's company and understand how they are restricted.). However, a new employee to whom this applies wasn't informed, so we learned that since the site now uses the AJAX add to cart process, the error message - which uses Joomla's &quot;enqueueMessage&quot; methods - no longer displays to the user until they move to some different page or physically reload.  The plugin still works the way it was written, and I see that I need to change onBeforeCartUpdate() to onBeforeCartSave(), but being AJAX, is there a way to deliver an error message to a user who fails to qualify for this AddToCart process?  Also, the AJAX interaction makes it very difficult to review the structure of the $element object argument. Is there full documentation of the $element object?")        Category: [Development](/forum/31-development "If you are developping a plugin for Hikashop or customizing our component, this is the board to be.")     Topic started 4 years 4 months ago, by [icomex](/forum/user/4967-icomex "View icomex's Profile")       [Last Post](/forum/31-development/904723-error-messages-using-ajax-addtocart#343205 "Hi,  To check if onBeforeCartUpdate is called, you can add such code at the beginning: var&#95;dump(debug&#95;backtrace());exit; That will output the callstack if called so you'll know where it is called from. I checked the whole code of HikaShop and I couldn't find onBeforeCartUpdate so I doubt it comes from HikaShop. Chances are that the message you see is coming from onBeforeCartSave. Note that undisplayed messages are stored in the session to be displayed later, when possible. So it might be this. Now, without knowing the code of that plugin and how the shop is configured, it will be hard to say exactly what's going on.") 4 years 4 months ago     by [nicolas](/forum/user/63-nicolas "View nicolas's Profile") | Replies:8  Views:1181 | [Last Post](/forum/31-development/904723-error-messages-using-ajax-addtocart#343205 "Hi,  To check if onBeforeCartUpdate is called, you can add such code at the beginning: var&#95;dump(debug&#95;backtrace());exit; That will output the callstack if called so you'll know where it is called from. I checked the whole code of HikaShop and I couldn't find onBeforeCartUpdate so I doubt it comes from HikaShop. Chances are that the message you see is coming from onBeforeCartSave. Note that undisplayed messages are stored in the session to be displayed later, when possible. So it might be this. Now, without knowing the code of that plugin and how the shop is configured, it will be hard to say exactly what's going on.") by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")      4 years 4 months ago |
| [](/forum/31-development/904385-custom-field-value-in-onbeforecalculateproductpriceforquantity-handler) | [Custom field value in onBeforeCalculateProductPriceForQuantity handler](/forum/31-development/904385-custom-field-value-in-onbeforecalculateproductpriceforquantity-handler "-- HikaShop version -- : 4.4.5 -- Joomla version -- : 4.1 -- PHP version -- : 7.4  Hi,  For testing purposes I created a &quot;Single Dropdown&quot; custom field for table &quot;item&quot;. The field shows up nicely in the front end on the product order form. I need the value in an onBeforeCalculateProductPriceForQuantity event handler but the field is not available in the parameter object. What am I doing wrong here?")        Category: [Development](/forum/31-development "If you are developping a plugin for Hikashop or customizing our component, this is the board to be.")     Topic started 4 years 6 months ago, by [pjdevries](/forum/user/64503-pjdevries "View pjdevries's Profile")       [Last Post](/forum/31-development/904385-custom-field-value-in-onbeforecalculateproductpriceforquantity-handler#341496 "Hi Nicolas,  Thanks. I'll try to figure out what's going wrong and get back to you if I can't find it.") 4 years 6 months ago     by [pjdevries](/forum/user/64503-pjdevries "View pjdevries's Profile") | Replies:2  Views:935 | [Last Post](/forum/31-development/904385-custom-field-value-in-onbeforecalculateproductpriceforquantity-handler#341496 "Hi Nicolas,  Thanks. I'll try to figure out what's going wrong and get back to you if I can't find it.") by [pjdevries](/forum/user/64503-pjdevries "View pjdevries's Profile")      4 years 6 months ago |
| [](/forum/31-development/904305-development-of-a-custom-field-documentation-and-or-help-needed) | [Development of a custom field - documentation and/or help needed](/forum/31-development/904305-development-of-a-custom-field-documentation-and-or-help-needed "-- HikaShop version -- : 4.4.5 -- Joomla version -- : 4.1 -- PHP version -- : 7.4  Is there any documentation available for creation of custom custom fields? I am making progress by looking at the datepickerfield plugin, but various bits are unclear to me, such as  Method plgHikashopDatepickerfield::onFieldsLoad() of the datepickerfield plugin sets a list of options I don't know what they are used for and whether I need all or any of them for my field.  For educational purposes I created a datepicker custom field to see how it's used and displayed. For some reason, that field not only displays the datepicker options, but also the options of my own custom field. I don't have a clue why that is.  Some pointers would be highly appreciated :)")        Category: [Development](/forum/31-development "If you are developping a plugin for Hikashop or customizing our component, this is the board to be.")     Topic started 4 years 6 months ago, by [pjdevries](/forum/user/64503-pjdevries "View pjdevries's Profile")       [Last Post](/forum/31-development/904305-development-of-a-custom-field-documentation-and-or-help-needed#341399 "Hi,  There is no option for that.") 4 years 6 months ago     by [nicolas](/forum/user/63-nicolas "View nicolas's Profile") | Replies:13  Views:1607 | [Last Post](/forum/31-development/904305-development-of-a-custom-field-documentation-and-or-help-needed#341399 "Hi,  There is no option for that.") by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")      4 years 6 months ago |
| [](/forum/31-development/904315-can-not-re-create-custom-field-with-same-column-name-as-deleted-field) | [Can not (re)create custom field with same column name as deleted field](/forum/31-development/904315-can-not-re-create-custom-field-with-same-column-name-as-deleted-field "-- HikaShop version -- : 4.4.5 -- Joomla version -- : 4.1 -- PHP version -- : 7.4  Not sure where to put this issue, so I'll do it here.  When deleting a custom field, it seems not possible to create a new custom field with the same Column&#95;name for the same Table. The reasons being that the field does get removed from the #&#95;&#95;hikashop&#95;field table but the actual table column is not removed from the table it was designated to.  Is this a bug or a feature?")        Category: [Development](/forum/31-development "If you are developping a plugin for Hikashop or customizing our component, this is the board to be.")     Topic started 4 years 6 months ago, by [pjdevries](/forum/user/64503-pjdevries "View pjdevries's Profile")       [Last Post](/forum/31-development/904315-can-not-re-create-custom-field-with-same-column-name-as-deleted-field#341347 "Hi,  In that case, you could always just use another column name. But yes, that could be useful, yes. We'll look at how we can improve things there. Thanks for your feedback.") 4 years 6 months ago     by [nicolas](/forum/user/63-nicolas "View nicolas's Profile") | Replies:5  Views:1102 | [Last Post](/forum/31-development/904315-can-not-re-create-custom-field-with-same-column-name-as-deleted-field#341347 "Hi,  In that case, you could always just use another column name. But yes, that could be useful, yes. We'll look at how we can improve things there. Thanks for your feedback.") by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")      4 years 6 months ago |
| [](/forum/31-development/904332-custom-email-template-tags-styling-override-issue) | [Custom email template - tags styling override issue](/forum/31-development/904332-custom-email-template-tags-styling-override-issue "-- HikaShop version -- : 4.5.1 -- Joomla version -- : 4.x -- PHP version -- : 8.x  Hi  I'm working on a custom template for emails sent by HIkashop on order update. I have a problem that the tag for custom fields ({TXT:CUSTOMFIELD&#95;NAME}) contain its own css style that I'm unable to override.  I've tried creating a  definition with .order-details-header td and simply change the color of the text, but the color is implemented with the !important classification for the color and therefore can't be overridden by the style in my  definition.  In my template I'm currently using this code with no inline style  The inline CSS that gets added to {TXT:CUSTOMFIELD&#95;NAME} is: border-bottom:1px solid #ddd;padding-bottom:3px;text-align:left;color:#1c8faf !important;font-size:12px;font-weight:bold;  This makes it hard to adopt the colors to match the website style. Any options to fix this?  Thanks")        Category: [Development](/forum/31-development "If you are developping a plugin for Hikashop or customizing our component, this is the board to be.")     Topic started 4 years 6 months ago, by [dyvel](/forum/user/39996-dyvel "View dyvel's Profile")       [Last Post](/forum/31-development/904332-custom-email-template-tags-styling-override-issue#341236 "Hi,  That's because the {TXT:CUSTOMFIELD&#95;NAME} tag can contain several columns. So the HTML has to be generated when the tag data is generated. However, that's not a problem. Edit your email, and instead of looking at the HTML version, scroll down to the &quot;preload version&quot;. There, you'll see all the PHP code of the email to generate all the tags used in the HTML version. And you'll see in particular that line:  so you can modify the HTML in there.") 4 years 6 months ago     by [nicolas](/forum/user/63-nicolas "View nicolas's Profile") | Replies:1  Views:1161 | [Last Post](/forum/31-development/904332-custom-email-template-tags-styling-override-issue#341236 "Hi,  That's because the {TXT:CUSTOMFIELD&#95;NAME} tag can contain several columns. So the HTML has to be generated when the tag data is generated. However, that's not a problem. Edit your email, and instead of looking at the HTML version, scroll down to the &quot;preload version&quot;. There, you'll see all the PHP code of the email to generate all the tags used in the HTML version. And you'll see in particular that line:  so you can modify the HTML in there.") by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")      4 years 6 months ago |
| <a id="forumbottom"> </a> [   ](#forumtop) |  |

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.045 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
