Adapt Your Add-Ons To Cs-Cart 4.1.3

[attachment=7845:ini2json.php]



[color=#000000][font=Arial][size=4]Hello, everybody![/size][/font][/color]



[color=#000000][font=Arial][size=4]To help developers adapt their add-ons to the new versions of CS-Cart, [/size][/font][/color]we decided to list the changes between the current and the previous versions of CS-Cart on every new release.

So, if your add-on deals with the CS-Cart code, please pay attention to this material.



[color=#000000][font=Arial][size=4]It is planned to make such compilations before each CS-Cart and Multi-Vendor release.[/size][/font][/color]

[color=#000000][font=Arial][size=4]We published this very first one after the release, but in the future we will try to make it in advance, [/size][/font][/color]so that you could have enough time to prepare your add-ons.



[color=#000000][font=Arial][size=4]After the release you will be able to find these changes at docs.cs-cart.com.[/size][/font][/color]



[color=#000000][font=Arial][size=4]If you want to add something to the compilation, [/size][/font][/color]feel free to write about it in the comments[color=#000000][font=Arial][size=4].[/size][/font][/color]

[color=#000000][font=Arial][size=4]We will surely add it to the list.[/size][/font][/color]





[size=5][color=#000000][font=Arial]CORE[/font][/color][/size]

[color=#000000][font=Arial][size=5]​=============================================[/size][/font][/color]



Now the “Add-ons” tab on the Vendor’s company editing page is displayed if there is any content to be displayed[color=#000000][font=Arial]. Earlier this tab was disabled for vendors.[/font][/color]

So, an add-on must check the content that is added by the following hook:



[color=#000000][font=Arial]{hook name="companies:detailed_content"}{/hook}[/font][/color]



----------------------------------------------------------------------------------------------------



[color=#000000][font=Arial]The following parameters of the installLanguagePack function were changed:[/font][/color]

[color=#000000][font=Arial]app/Tygh/Languages/Languages.php[/font][/color]

[color=#b22222][font=Arial]– public static function installLanguagePack($pack_path, $reinstall = false)[/font][/color]

[color=#006400][font=Arial]+ public static function installLanguagePack($pack_path, $params = array())[/font][/color]



[color=#000000][font=Arial]Now, using this function one should pass the parameters in the array:[/font][/color]


$params = array(
'reinstall' => false, // Skip adding new language
'validate_lang_code' => , // Check meta information (lang_code) with updated language data (lang_code) and forbid to update if does not match
);




----------------------------------------------------------------------------------------------------



Parameters of the batchRender and render functions of the Pdf class were also changed:

[color=#000000][font=Arial]app/Tygh/Pdf.php[/font][/color]

[color=#b22222][font=Arial]– public static function batchRender($filename = , $save = false)[/font][/color]

[color=#006400][font=Arial]+ public static function batchRender($filename = , $save = false, $params = array())[/font][/color]



[color=#b22222][font=Arial]– public static function render($html, $filename = , $save = false)[/font][/color]

[color=#006400][font=Arial]+ public static function render($html, $filename = '', $save = false, $params = array())[/font][/color]



Now the page size can be defined in the $params:


$params = array(
'page_size' => 'A4'
);




----------------------------------------------------------------------------------------------------



[color=#000000][font=Arial]Be careful with such code:[/font][/color]

[color=#b22222][font=Arial]– unset($cart['products'][$k]);[/font][/color]

[color=#008000][font=Arial]+ fn_delete_cart_product($cart, $k);[/font][/color]

A product is be removed from cart with the fn_delete_cart_product function; unsetting the state isn't enough.



----------------------------------------------------------------------------------------------------



All Google Checkout-related code was removed[color=#000000][font=Arial]. So, if your add-on is still using any functions or hooks relating to Google Checkout, remove them.[/font][/color]



----------------------------------------------------------------------------------------------------



[color=#000000][font=Arial]The parameters of the [/font][/color][color=#000000][font=Arial]fn_check_added_required_products [/font][/color][color=#000000][font=Arial]function were changed:[/font][/color]

[color=#000000]font=Arial[/font][/color]

[color=#b22222][font=Arial]–function fn_check_added_required_products(&$product_data, $auth, $added_products = array())[/font][/color]

[color=#006400][font=Arial]+function fn_check_added_required_products(&$product_data, $auth, &$cart, $added_products = array())[/font][/color]



----------------------------------------------------------------------------------------------------



Now, theme manifest is stored in the manifest.json file instead of manifest.ini. (We plan to provide the legacy manifest.ini support in CS-Cart and Multi-Vendor 4.1.4).[color=#000000][font=Arial] [/font][/color]Use the attached script to convert existing manifest.ini files to manifest.json in your themes. Place the script into the root directory of your installation and launch it.



----------------------------------------------------------------------------------------------------



Registry entry settings.General is now referred to as config.tweaks. Instead of:

[color=#b22222][font=Arial]Registry::get('settings.General.redirect_to_cart’) [/font][/color]



you should use:

[color=#006400][font=Arial]Registry::get('config.tweaks.redirect_to_cart’)[/font][/color]



----------------------------------------------------------------------------------------------------



In the fn_start_payment function, the $payment_info parameter is no longer mandatory.

[color=#b22222][font=Arial]–function fn_start_payment($order_id, $force_notification = array(), $payment_info)[/font][/color]

[color=#006400][font=Arial]+function fn_start_payment($order_id, $force_notification = array(), $payment_info = array())[/font][/color]



----------------------------------------------------------------------------------------------------



[color=#000000][font=Arial]The [/font][/color][color=#000000][font=Arial]fn_error[/font][/color][color=#000000][font=Arial] function is removed. Use the exceptions instead.[/font][/color]



----------------------------------------------------------------------------------------------------



[color=#000000][font=Arial]The [/font][/color][color=#000000][font=Arial]fn_decompress_files($archive_name, $dirname = ‘’) [/font][/color][color=#000000][font=Arial]function:[/font][/color]

[color=#000000][font=Arial]If [/font][/color][color=#000000][font=Arial]$dirname[/font][/color][color=#000000][font=Arial] is empty:[/font][/color]

[color=#000000][font=Arial]In CS-Cart and Multi-Vendor 4.1.3 [/font][/color][color=#000000][font=Arial]$dirname[/font][/color][color=#000000][font=Arial] has the[/font][/color][color=#000000][font=Arial] getcwd()[/font][/color][color=#000000][font=Arial] value.[/font][/color]

[color=#000000][font=Arial]In CS-Cart and Multi-Vendor 4.1.4 [/font][/color][color=#000000][font=Arial]getcwd[/font][/color][color=#000000][font=Arial] will be replaced with [/font][/color][color=#000000][font=Arial]$dirname = Registry::get('config.dir.files’);[/font][/color]

Now, the full path to the target directory is defined in the dirname param.







[size=5][color=#000000][font=Arial]HOOKS CHANGES[/font][/color][/size]

[size=5][color=#000000][font=Arial]=============================================[/font][/color][/size]





[color=#000000][font=Arial]The following hooks were expanded:[/font][/color]

[color=#b22222][font=Arial]– fn_set_hook('get_categories_after_sql', $categories);[/font][/color]

[color=#006400][font=Arial]+ fn_set_hook('get_categories_after_sql', $categories, $params);[/font][/color]



[color=#b22222][font=Arial]– fn_set_hook('redirect_complete');[/font][/color]

[color=#006400][font=Arial]+ fn_set_hook('redirect_complete', $meta_redirect);[/font][/color]



[color=#b22222][font=Arial]– fn_set_hook('get_categories_after_sql', $categories);[/font][/color]

[color=#006400][font=Arial]+ fn_set_hook('get_categories_after_sql', $categories, $params);[/font][/color]



The newly added hooks are not described here, only the ones that changed. Refer to our Hook Base to see all the hooks in all CS-Cart and Multi-Vendor versions.

ini2json.php

Thanks for this info. Bookmarked.

@alexions,



Thanks. Very helpful!

Excellent. Looking forward to being able to sync addon changes required for a new release when a new release becomes available rather than having it be a discovery process.



But just so you know, using fn_decompress_files($archive_name, './') still generates the _tmp file failure error notification, but the archive does seem to be extracted properly. “./” should be a valid path for the function.



Now, if changes to an addon.xml file processing could be picked up so that new parameters can be added and/or language values updated without having to uninstall/install an addon, it would be great! User should only have to 'Save' to pick up changes. Now, the control shows (if any) without any title field. I.e. a blank and a checkbox for a new checkbox entry in addon.xml.

Thank you. This will help us in add-ons compatibility check.

[quote name='tbirnseth' timestamp='1395343813' post='179694']

Excellent. Â Looking forward to being able to sync addon changes required for a new release when a n

ew release becomes available rather than having it be a discovery process.

Â

But just so you know, using fn_decompress_files($archive_name, './&#39:wink: still generates the _tmp file

failure error notification, but the archive does seem to be extracted properly. Â "./" should be a v

alid path for the function.

[/quote]

Â

As we discussed before, you should use the full path or not specify it at all. The function gets it

 from getcwd(). (getcwd will be removed in 4.1.4). Yes, the backward compatibility was broken here,

 but this is default behaviour of the built-in Phar functionality.

Â

[quote name='tbirnseth' timestamp='1395343813' post='179694']

Now, if changes to an addon.xml file processing could be picked up so that new parameters can be ad

ded and/or language values updated without having to uninstall/install an addon, it would be great!

 User should only have to 'Save' to pick up changes.  Now, the control shows (if any) without any

title field. Â I.e. a blank and a checkbox for a new checkbox entry in addon.xml.

[/quote]

Â

Add-ons use the default Settings system, so it is quite hard to check and create new structures on

every update.

I know that you use your upgrade system, so you can update your add-on the "Store import" way. Check

 the "Store import" add-on.

Â

This way is:

  1. Save values of settings
  2. Delete all settings of the add-on
  3. Create a new structure
  4. Restore values

    Â

    Thank you!

Still like to know why using “./” as the path argument (rather than a full path) generates the error message about the _tmp file, but the archive extracts okay. I still contend that “./” is a valid “path” and that NO php library function should require a full path to operate properly. BTW, I have also seen the _tmp file failure message when using a full path for the path argument. It could be that there is a permissions problem at the site and the message is erroneous.



Regarding the settings… When saved, the language variables should be updated as well as any 'function' tags that exist. Seems to me that the “system” should do what you suggest above for me rather than having me do that myself. You have all the info there between the existing settings and the xml information. Right now, the setting “control” is there (checkbox, input, radiogroup, etc.) but there is no title (I.e. if I added a checkbox item for “test mode”, “test mode” will not display, but the checkbox will). I “think” that if I checked the box, that the setting is in fact applied. I'm more interested in new things that are added than deleting ones that no longer apply. It's certainly not critical, but would seem like a valuable extension for those of us who don't have the luxury of embedding support for our addons in the product release.

Dear Tony,



Yes, you are actually right. The best way is to let the system make the necessary modifications automatically.

We will think about this point and how to help you and other developers to improve their add-ons.



Best wishes!

Thanks… I know for me, that I make incremental changes and need to be able to account for 'additions' without having the user uninstall/install the addon (they could loose customizations if they do).



I already process language variables outside the addon.xml since this was a long-term need (all my controllers have a 'install_lang_vars' mode that can be done at anytime and is automatically done on upgrade). But having the ability to specify new addon settings for user selection in an updated addon.xml would be a big plus. Otherwise I have to move all the addon settings out of the addon.xml and into their own settings/manage pages which kind of defeats the purpose for the addon.xml.



Again, thanks for considering it.

Hello may i know the documentation about paramenter can be used on render function?



I want to create custom packing slip(pdf) size



i try is :



$default_params = array(
'content' => $html,
//'page_size' => 'A4'
'page_width' => '870px',
'page_height' => '396px'
);




but the object / content was missing, maybe we must precisely set the margin / axis / something in that?



Thank you

[quote name='kkzhi' timestamp='1436146054' post='221678']

Hello may i know the documentation about paramenter can be used on render function?



I want to create custom packing slip(pdf) size



i try is :



$default_params = array(
'content' => $html,
//'page_size' => 'A4'
'page_width' => '870px',
'page_height' => '396px'
);




but the object / content was missing, maybe we must precisely set the margin / axis / something in that?



Thank you

[/quote]



The PDF generator code is published at github: GitHub - bzzeke/pdf: pdf

Hope this will help)