Jump to content

Search the Community

Showing results for tags 'documentation'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • News and Annoucement
    • Latest news for community
  • ClicShoppingV3
    • Documentation
    • Installation & Configuration & Operation
    • Adds On / Modules / Hooks /Apps
    • Community Developement
    • Best pratices / tip / trips and training
  • General
    • Optimization / Marketing
    • Laws on E-commerce
    • General discussions
    • Archives


  • E-commerce General
  • ClicShopping


  • Apps
    • Apps Payment
    • Apps Configuration
    • Apps Shipping
    • Apps Catalog
    • Apps Communication
    • Apps Customers
    • Apps Marketing
    • Apps Orders
    • Apps Order Total
    • Apps Products Listing
    • Apps Report
    • Apps Social Network
    • Apps Tools
    • Apps Web Service
  • Template
    • modules_boxes
    • modules_products_info
    • modules_front_page
    • modules_footer
    • modules_header
    • modules_index_categories
    • modules_account_customers
    • Design template
    • modules_products_featured
    • modules_products_heart (favorites)
    • modules_blog
    • modules_blog_content
    • modules_checkout_confirmation
    • modules_checkout_payment
    • modules_checkout_shipping
    • modules_checkout_success
    • modules_tell_a_friend
    • modules_contact_us
    • modules_create_account
    • modules_create_account_pro
    • modules_advanced_search
    • modules_login
    • modules_products_listing
    • modules_products_new
    • modules_products_reviews
    • modules_products_search
    • modules_products_special
    • modules_shopping_cart
    • modules_sitemap
    • Autres modules
  • Hooks
    • Modules Hooks ClicShoppingAdmin - Orders
    • Modules Hooks Shop - AllShop
    • Modules Hooks Shop - Checkout
    • Modules Hooks Shop - Info
    • Modules Hooks Shop - Others
    • Modules Hooks ClicShoppingAdmin - Dashboard
    • Modules Hooks ClicShoppingAdmin - Import Databse
    • Modules Hooks ClicShoppingAdmin - Others
  • Languages
  • modules
    • modules Action Recorder
    • modules Header tags
    • modules Social bookmarks
    • modules Others
  • Modules
    • Modules Export
    • Modules Imports
    • Modules Others
    • Modules Dashbioard

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start



About Me

Found 12 results

  1. Email is part of communication, below different examples how to set email inside ClicShopping Example 1 : o2switch.net User name : myemail@domain.com - Password : email password - Server : mail.test.domain.com - remove mail. and write only test.domain.com - SMTP Port: 26 - SMTP authentication : true - SMTP secured protocol : ssl - Emails activation : true Example 2 : gmail.com - User name : myemail@gmail.com - Password : Utilisez le mot de passe du compte de messagerie. - Server smtp : smtp.gmail.com - remove smtp. and write only gmail.com - SMTP Port: 25 ou 465 - SMTP authentication : true - SMTP secured protocol : ssl or Tls - Emails activation : true
  2. When Google or other search engines come to your site to read and store the content in its search index, it will look for a special file called robots.txt. This file is a set of instructions to tell search engines where they can look to crawl content and where they are not allowed to crawl content. We can use these rules to ensure that search engines don't waste their time looking at links that do not have valuable content and avoid links that produce faceted content. Why is this important? Search engines need to look at and store as many pages that exist on the internet as possible. There are currently an estimated more 4.5 billion web pages active today. That's a lot of work for Google. It cannot look and store every single page, so it needs to decide what to keep and how long it will spend on your site indexing pages. This is called a crawl budget. How many pages a day Google will index depends on many factors, including how fresh the site is, how much content you have and how popular your site is. Some websites will have Google index as few as 30 links a day. We want every link to count and not waste Google's time. What does the suggested Robots.txt file do? ClicShopping optimised rules exclude site areas with no unique content but instead redirect links to existing topics. Also excluded are areas such as the privacy policy, cookie policy, log in and register pages and so on. Submit buttons and filters are also excluded to prevent faceted pages. Finally, user profiles are excluded as these offer little valuable content for Google but contain around 150 redirect links. Given that Google has more seconds on your site, these links that exist elsewhere eat up your crawl budget quickly. What is the suggested Robots.txt file? Here is the content of the suggested Robots.txt file. If your ClicSHoppingis inside a directory, you will need to apply it to the root of your site manually. So, for example, if your community was at /home/site/public_html/myDirectory/ - you would need to create this robots.txt file and add it to /home/site/public_html. It's simple just edit robot.txt and change inside the information example of robot.txt Note : domain.ltd must be changed by your domain. # Rules for ClicSopping (https://www.clicshopping.org) User-Agent: * # Block pages with no unique content Disallow: /Account/LogIn/ Disallow: /Account/CreatePro Disallow: /Account/Create Disallow: /Account/PasswordForgotten Disallow: /Search/AdvancedSearch/ Disallow: /Search/Q/ # Block faceted pages and 301 redirect pages Disallow: /*?page= Disallow: /*?sort= # Sitemap URL Sitemap: https://domain.tld/index.php?Sitemap&GoogleSitemapIndex
  3. The version 3.323 allows to use htaccess to rewrite the url. To use this function you must activate in Shop/SEO urls this 2 options 1 - Use Search-Engine Safe Native URLs this option rewrites the url like this : https://demo.clicshopping.org/index.php/Products/Description/logitech-trackman-marble-mouse/Id-12 and 2- Use Search-Engine Safe URLs Pro (with htaccess) This option rewrites the url like this : https://demo.clicshopping.org/Products/Description/logitech-trackman-marble-mouse/Id-12 To use the last option, you must include inside your root an htaccess with this syntax. Of course, it can updated in function of your server. note : This option works only on the catalog without customer, if your are logged you will see the url above. It's optimized only for the search engine. For apache 2.4 ################################## # url rewiting #improve url rewriting #work fine without directory https://mydomain.com/test/index.php #the rewriting must be activated inside the application # uncomment ################################## <IfModule mod_rewrite.c> RewriteEngine On DirectorySlash Off # # Remove WWW # RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] RewriteRule ^ https://%1%{REQUEST_URI} [R=302,L] # # Remove Trailing Slashes # RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{THE_REQUEST} \s(.+?)//+[?\s] RewriteRule ^ %1 [R=302,L] # # Reroute to index.php # RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L] </IfModule>
  4. With PHP 7.4, support for preloading was added, a feature that could improve the performance of your code significantly. In a nutshell, this is how it works: - In order to preload files, you need to write a custom PHP script - This script is executed once on server startup - All preloaded files are available in memory for all requests - Changes made to preloaded files won't have any effect, until the server is restarted If you want more information, some article are available on this new feature. library used (under MIT licence): https://github.com/DarkGhostHunter/Preloader 1 / Mandatory Requirement - Php 7.4 minimum version - opCache installed - An access to your php.ini - Work in 777 chmod 2 / How to implement : Step 1 : Know your path You must know your root on preloader.php inside your application. below an example www/var/..../shop/includes/ClicShopping/Work/Log/preloader.php Step 2 : Php.init implementation Edit your php.init and search this line : ;opcache.preload= replace by your root path : below an example opcache.preload=/home/www/..../shop/includes/ClicShopping/Work/Log/preloader.php Step4 : Restart apache2 Make this command inside your terminal sudo service apache2 restart Step5 : Configure ClicShopping * Go to ClicShopping Administration - Menu Configuration / Session & Cache / Compression & optimization - Activate the preload functionnalities * Go to your catalog and actualise a page - The sytem will create a preloader.php file inside your Work/Log directory - You can check if everything is correct in editing your preload.php files. You must see some information inside.
  5. This tuto allow to make an app quickly without knowledge. Inside you will have important element to use and change to create a new app. you must after updated inside your need. - First download a App name New_Template on Github and follow these instructions (https://github.com/ClicShoppingOfficialModulesV3/apps_catalog_new_template) - Copy the app New_Template inside your includes/Apps/Catalog directory - Rename the directory New_Template by MY_NEWS_APP (name of your new application) - Replace all these terms in my MY_NEWS_APP directory : Please respect the syntax lower and uppercase. it's very important. - NewTemplateAdmin by MyNewAPPAdmin - new_template by my_new_app - New_Template by My_New_APP - NEW_TEMPLATE by MY_NEWS_APP - NT BY MA ==> becarefull when you make that. - _nt_ by _ma_ Rename directories and files - New_Template.php by My_New_App.php - new_template.php by my_new_app.php - NT.php by MA.php - NT by MA - Inside this directory Sites\ClicShoppingAdmin\Pages\Home\Actions\Configure - edit Install.php - Update in consequence. - Update the language files Note These directories has been inserted to help you. If you don't need, you can remove. - Remove Classes directories if you don't have need. - Remove Hooks language and Products directory if you don't have need. Don"t forget to update your clicshopping.json If you need specific classes, create a specific directories ClicShoppingAdmin for the admin and Shop for the catalog. now you are ready, you can find some apps to help you to continue your development on Github : https://github.com/ClicShoppingOfficialModulesV3 Now you ready to install you new app. https://www.mydomain.net/shop/ClicShoppingAdmin/index.php?A&MY_NEWS_APP
  6. This tuto help you how to create a module to be downloaded from github communiy or official add on. In the future, it will be integrated (maybe) inside the application to allow the community to push their module on GitHub ClicShopping community. In this tuto, we create a new module called: module_header_tags_favicon Note,: In different apps, you can also create a header tag module: For example like products app to include an header tag facebook. If you module header tag is used in all the website, it's better to follow this example. Very important: All the modules start must begin by : module_ module_apps_best_selling, module_header_tags_touch_icon, modules_header_bootstrap_caroussel The structure of the directory module_header_tags_favicon ===> note : the directory must have the same name of your module readme.md LICENCSE -- includes ----modules ----header_tags -- ModulesInfosJson -- sources ---- images ------ icons ---- languages ------ english -------- modules ----------header_tags ------ french -------- modules ----------header_tags Step 1 Insides this directory : header_tags create a file called ht_favicon.php -- includes ----modules ----header_tags ----- ht_favicon.php insert this code <?php /** * * @copyright 2008 - https://www.clicshopping.org * @Brand : ClicShopping(Tm) at Inpi all right Reserved * @Licence GPL 2 & MIT * @licence MIT - Portion of osCommerce 2.4 * @Info : https://www.clicshopping.org/forum/trademark/ * */ use ClicShopping\OM\Registry; use ClicShopping\OM\HTTP; use ClicShopping\OM\CLICSHOPPING; class ht_favicon { public $code; public $group; public $title; public $description; public $sort_order; public $enabled = false; public function __construct() { $this->code = get_class($this); $this->group = basename(__DIR__); $this->title = CLICSHOPPING::getDef('module_header_tags_favicon_title'); $this->description = CLICSHOPPING::getDef('module_header_tags_favicon_description'); if ( defined('MODULE_HEADER_TAGS_FAVICON_STATUS') ) { $this->sort_order = MODULE_HEADER_TAGS_FAVICON_SORT_ORDER; $this->enabled = (MODULE_HEADER_TAGS_FAVICON_STATUS == 'True'); } } public function execute() { $OSCOM_Template = Registry::get('Template'); $extansion_favicon = MODULE_HEADER_TAGS_FAVICON_EXTENSION_FAVICON; $OSCOM_Template->addBlock('<link rel="icon" type="image/' . $extansion_favicon . '" href="' . HTTP::getShopUrlDomain() . 'sources/images/icons/favicon.' . $extansion_favicon . '">', $this->group); } public function isEnabled() { return $this->enabled; } public function check() { return defined('MODULE_HEADER_TAGS_FAVICON_STATUS'); } public function install() { $CLICSHOPPING_Db = Registry::get('Db'); $CLICSHOPPING_Db->save('configuration', [ 'configuration_title' => 'Do you want install this module ?', 'configuration_key' => 'MODULE_HEADER_TAGS_FAVICON_STATUS', 'configuration_value' => 'True', 'configuration_description' => 'Do you want activate this module ?', 'configuration_group_id' => '6', 'sort_order' => '1', 'set_function' => 'osc_cfg_set_boolean_value(array(\'True\', \'False\'))', 'date_added' => 'now()' ] ); $CLICSHOPPING_Db->save('configuration', [ 'configuration_title' => 'Choose favicon extansion ?', 'configuration_key' => 'MODULE_HEADER_TAGS_FAVICON_EXTENSION_FAVICON', 'configuration_value' => 'png', 'configuration_description' => 'Extansion allowed : png, gif ou ico : <br /><br /><strong>Note :</strong><br /><br />- The favicon must be in the sources/image/icons directory', 'configuration_group_id' => '6', 'sort_order' => '1', 'set_function' => 'osc_cfg_set_boolean_value(array(\'png\', \'gif\', \'ico\'))', 'date_added' => 'now()' ] ); $CLICSHOPPING_Db->save('configuration', [ 'configuration_title' => 'Display sort order', 'configuration_key' => 'MODULE_HEADER_TAGS_FAVICON_SORT_ORDER', 'configuration_value' => '75', 'configuration_description' => 'Display sort order (lower is displayed in first)', 'configuration_group_id' => '6', 'sort_order' => '55', 'set_function' => '', 'date_added' => 'now()' ] ); return $CLICSHOPPING_Db->save('configuration', ['configuration_value' => '1'], ['configuration_key' => 'WEBSITE_MODULE_INSTALLED'] ); } public function remove() { return Registry::get('Db')->exec('delete from :table_configuration where configuration_key in ("' . implode('", "', $this->keys()) . '")'); } public function keys() { return array('MODULE_HEADER_TAGS_FAVICON_STATUS', 'MODULE_HEADER_TAGS_FAVICON_EXTENSION_FAVICON', 'MODULE_HEADER_TAGS_FAVICON_SORT_ORDER'); } } Step 2 : In ModuleInfosJson directory, create module_header_tags_favicon.json ModuleInfosJson -- module_header_tags_favicon.json Note : module_header_tags_favicon.json has the same namo of you root directory the json must have these elements { "title": "module_header_tags_favicon", "type": "meta tag", "vendor": "ClicShopping", "is_free": "yes", "is_free": "no", "website_link_to_sell" : "", "version": 1.0, "req_core_version": 3.0, "license": "GPL 2", "tag": "header tag, script, meta tag, favicon", "install": "includes/modules/", "module_directory": "header_tags", "apps_name": "", "type_module": "fixe", "dependance": "", "description": "This module allow you to insert a favicon inside your site", "image": "", "authors": [ { "name": "ClicShopping Team", "company": "", "email": "", "website": "", "Community": "http://www.clicshopping.org" } ] } Note on the most important json elements : - title must have the same name of your directory - type : apps or modules_directory (ex : modules_footer) - is_free : Yes or No (if no include your link in website_link_to_sell) - is_core : Yes or No - type module : fixe or template - dependance : if you must have another module to use this module. For example a hook - module_directory: Module directory - apps_name : Apps Directory name Step 3 : Image In icons directory -- sources ---- images ------ icons In icons directory insert : favico.gif, favicon.ico, favicon.png Step 4 Languages ---- languages ------ english -------- modules ----------header_tags ------ french -------- modules ----------header_tags In each header_tags directory insert this file : ht_favicon.txt and include inside for english : module_header_tags_favicon_title = Do you want use Favicon balise module_header_tags_favicon_description = Add favicon balise in the store for french : module_header_tags_favicon_title = Souhaitez utiliser la balise Favicon pour afficher une petite image à cotè de l'URL ? module_header_tags_favicon_description = Ajouter une petite image en 64x64 à coté de l'URL
  7. ClicShopping 3.X allow you to use use hooks inside your App to increase the functionalities in others App. To use this element you can have different choice depends with the app than you want to use Use the Hooks In hooks you have 2 choices : output to display an information call to use a function. $CLICSHOPPING_Hooks->call('Orders','Update'); $CLICSHOPPING_Hooks->ouput('Orders','ContentTracking', null 'display); To use the hook with call you can have different choices depending of the Hooks : The best is to look this directory inside the original hook where you want to include anew functionalities : ClicShopping/Apps/Products/ExtraFields/Modules/Hooks/ClicShoppingAdmin/ExtraFields $CLICSHOPPING_Hooks->call('Products','Insert'); $CLICSHOPPING_Hooks->call('Products','Update'); $CLICSHOPPING_Hooks->call('Products','Delete'); $CLICSHOPPING_Hooks->call('Products','Save'); At end, don't forget to insert in the clicshopping.json the new hook Display a Hooks About to display a hooks inside the page you can you something like that <div id="ContentTabQuantityDiscount"> in the original files you want to modify inside the hooks you can use this element to display the information. it could a new tab or inside a tab a content. For a Tab $dejardins_button = HTML::button('button_name'); $content = '<div> Desjardi</div>; $output = <<<EOD <div class="tab-pane" id="section_CMCICApp_content"> <div class="mainTitle"></div> <div class="adminformTitle"> <div class="separator"></div> {$dejardins_button} {$content} </div> </div> <script> $('#section_CMCICApp_content').appendTo('#orderTabs .tab-content'); $('#orderTabs .nav-tabs').append(' <li class="nav-item"><a data-target="#section_CMCICApp_content" role="tab" data-toggle="tab" class="nav-link">{$tab_title}</a></li>'); </script> EOD; For a content you can use append or prepend $content = '<div>mycontent</div>'; $output = <<<EOD <!-- ######################## --> <!-- Start SpecialsApp --> <!-- ######################## --> <script> $('#tab9Content').prepend( '{$content}' ); </script> <!-- ######################## --> <!-- End SpecialsApp --> <!-- ######################## --> EOD; For more informations, see the Hooks documentation
  8. The default template doesn't contain all informations that you can display in the template. If you need more informations, you must create a new template and use this syntax. Of course, if you want more options to display or not, you can create a new module and insert new option than you can manage in the back office. There the main information you can use. $products_name : Display the product name $products_stock : Display the product stock (image or text) $products_short_description : Display a short product description $products_flash_discount : Display the flash discount about a product $min_order_quantity_products_display : Display the min order than you accept for one order $product_price : display the product price $submit_button_view : display a message in function the customers group $submit_button : add button to take an order $products_quantity_unit : display the quantity of the unit to take an order $products_weight : display the product weight $button_small_view_details : Display the button to go in the product description $products_image : display the product image $ticker : display the ticker $products_model : display the product model $products_manufacturers : display the product manufacturer/ brand $products_date_available : display the product availabity $products_only_shop : display if the product is only available on the shop $products_only_web : display if the product is only available on the web $products_packaging : display the product packaging $products_shipping_delay : display the shipping delay $products_tag : display the product tag $products_volume : display the product volume $avg_reviews : display reviews Average with star $jsonLtd : display product Json Meta data
  9. Hooks ClicShopping\OM\Hooks Introduction Hooks allow action callouts to be thrown during an event to execute additional functionality. Hooks are not modules in the traditional sense of being able to be installed and configured; they are simply modular functions waiting to be executed on demand with no configuration or administration whatsoever. For security reasons, hooks must be defined in their Apps metadata file otherwise they will not be made available for the framework to use. Hooks are initialized by creating an instance of ClicShopping\OM\Hooks and specifying the Site to call the hook action from. If no Site is passed, the Site that initialized the framework is used as default. use ClicShopping\OM\Hooks; $CLICSHOPPING_Hooks = new Hooks(); Hooks() is automatically initialized on each page request and is available in the Registry as Hooks. Action Callout Throwing out an action callout is performed by specifying the group the action belongs to, the actual action name, and optionally a specific function to execute. There are two types of callouts that can be peformed: Type Description call() Executes the hooks and can return an array of results depending on the action. output() Executes the hooks and returns the output as a string. Hooks::call() // no output expected $CLICSHOPPING_Hooks->call('Account', 'Logout'); Parameters Hooks::call($group, $hook, $parameters, $action) Parameter Value $group The group the action call belongs to. $hook The name of the action to call. $parameters Any parameters to pass to the hooks. $action The name of the hook function to execute. Default: execute Hooks::output() // concatenated string output of all hooks executed echo $CLICSHOPPING_Hooks->output('Orders', 'Page', null, 'display') Parameters Hooks::output($group, $hook, $parameters, $action) The output() method shares the same function parameters as the call() class method. A list of hook action callouts is available on the List of Hook Callouts page. Runtime Watches Runtime watches can be defined that execute when the hook is called. This differs from hooks defined in App metadata files as they are defined in-line and execute either an existing function or are defined with an anonymous function to execute: use ClicShopping\OM\Registry; $CLICSHOPPING_Hooks = Registry::get('Hooks'); $CLICSHOPPING_Hooks->watch('Session', 'Recreated', 'execute', function($parameters) { .... });
  10. Database ClicShopping\OM\Db Introduction The Db class manages the connection to the database server and executes sql queries. It extends the native PHP PDO class with custom functionality optimized to the framework. The class executes sql queries safely and securely by binding parameter values to the query via placeholders rather then having the values being injected into the sql query itself. Connections Db::initialize() opens a new connection to the database server. All parameters of the function are optional where the installation configuration values are used as default values. use ClicShopping\OM\Db; $CLICSHOPPING_Db = Db::initialize(); Parameters Db::initialize($server, $username, $password, $database, $port, array $driver_options) Parameter Value $server The address of the database server. Default: db_server $username The username to connect to the database server with. Default: db_server_username $password The password of the user account. Default: db_server_password $database The name of the database. Default: db_database $port The port number of the database server. Default: null $driver_options Additional driver options to use for the database connection. Defaults: PDO::ATTR_ERRMODE PDO::ERRMODE_WARNING PDO::ATTR_DEFAULT_FETCH_MODE PDO::FETCH_ASSOC PDO::ATTR_STATEMENT_CLASS ClicShopping\OM\DbStatement PDO::MYSQL_ATTR_INIT_COMMAND set session sql_mode="STRICT_ALL_TABLES,NO_ZERO_DATE,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION" A database connection is created on each page request and is available in the Registry as Db. Queries Prepared Statements Queries are performed with Db::prepare() which securely binds values to the query using placeholders. $seach = 'chocolate'; $category_id = 1; $price = '4.99'; $Qproducts = $CLICSHOPPING_Db->prepare('select title from :table_products where description like :description and category_id = :category_id and status = :status and price < :price order by title'); $Qproducts->bindValue(':description', '%' . $chocolate . '%'); $Qproducts->bindInt(':category_id', $category_id); $Qproducts->bindBool(':status', true); $Qproducts->bindDecimal(':price', $price); $Qproducts->execute(); while ($Qproducts->fetch()) { echo $Qproducts->value('title'); } Binding Parameters Parameters can be binded to the query using the following functions: Value Type Function String bindValue Integer bindInt Boolean bindBool Decimal bindDecimal Null bindNull [code] Table names prefixed with [b]:table_[/b] are binded and prefixed automatically with db_table_prefix. [b]Single Function Calls[/b] [b]Select Queries[/b] Simple select queries that do not need parameters to be binded can be executed with Db::query(). This functions returns a normal result set. [code] $Qstates = $CLICSHOPPING_Db->query('select id, title from :table_states where country_id = 1 order by title'); while ($Qstates->fetch()) { echo $Qstates->value('title'); } Update/Delete Queries Simple update/delete queries that do not need parameters to be binded can be executed with Db::exec(). This functions returns the number of rows affected. $result = $CLICSHOPPING_Db->exec('delete from :table_states where country_id = 1'); echo 'Affected rows: ' . $result; [code] [b]Results[/b] Results can be returned as a single result set, a multiple result set, and as an array containing all rows or columns. Fetching [b]Single Result Set[/b] Returning a single result set is performed as: [code] $Qstate = $CLICSHOPPING_Db->prepare('select title from :table_states where id = :id'); $Qstate->bindInt(':id', 1); $Qstate->execute(); if ($Qstate->fetch() !== false) { echo 'State: ' . $Qstate->value('title'); } Multiple Result Set Returning a multiple result set is performed as: $Qstates = $CLICSHOPPING_Db->prepare('select id, title from :table_states where country_id = :country_id'); $Qstates->bindInt(':country_id', 1); $Qstates->execute(); while ($Qstates->fetch()) { echo 'State: ' . $Qstates->value('title'); } Array Result Set An array can be retrieved containing either all rows of the result set or all columns of the current row: $Qstates = $CLICSHOPPING_Db->prepare('select id, title from :table_states where country_id = :country_id'); $Qstates->bindInt(':country_id', 1); $Qstates->execute(); $states_all = $Qstates->fetchAll(); $current_state = $Qstates->toArray(); Result Exists Checking to see if a result exists is performed as: $Qstates = $CLICSHOPPING_Db->prepare('select id, title from :table_states where country_id = :country_id'); $Qstates->bindInt(':country_id', 1); $Qstates->execute(); if ($Qstates->fetch() !== false) { echo 'States:'; do { echo $Qstates->value('title'); } while ($Qstates->fetch()); } else { echo 'No states exist.'; } Please note that the following will not work: $Qstates = $CLICSHOPPING_Db->prepare('select id, title from :table_states where country_id = :country_id'); $Qstates->bindInt(':country_id', 1); $Qstates->execute(); if ($Qstates->fetch() !== false) { echo 'States:'; while ($Qstates->fetch()) { echo $Qstates->value('title'); } } as calling fetch() in the if statement to check if a row exists and looping through the results again in the while statement will skip the first row of the result set due to the first call to fetch(). The do { .. } while ( .. ) method shown above is the correct way. Type Hinting Columns can be returned as a specific variable type using the following functions: Value Type Function String value HTML Safe String valueProtected Integer valueInt Decimal valueDecimal $Qproducts = $CLICSHOPPING_Db->prepare('select id, title, code, price from :table_products where description like :description order by title'); $Qproducts->bindValue(':description', '%chocolate%'); $Qproducts->execute(); if ($Qproducts->fetch() !== false) { do { echo $Qproducts->valueInt('id') . ': ' . $Qproducts->valueProtected('title') . ' (' . $Qproducts->value('code') . ') = ' . $Qproducts->valueDecimal('price'); } while ($Qproducts->fetch()); } [code] [b]Affected Rows[/b] The number of rows affected by an insert, update, or delete query can be returned as: [code] $Qupdate = $CLICSHOPPING_Db->prepare('update :table_states set title = :title where id = :id'); $Qupdate->bindValue(':title', 'Beverly Hills'); $Qupdate->bindInt(':id', 1); $Qupdate->execute; echo 'Affected rows: ' . $Qupdate->rowCount(); Please do not use rowCount() for select queries as this is not supported by PDO. Total Rows Retrieving the total rows of a query can be performed as: $Qtotal = $CLICSHOPPING_Db->prepare('select SQL_CALC_FOUND_ROWS id from :table_orders where status = :status'); $Qtotal->bindBool(':status', true); $Qtotal->execute(); echo 'Total rows: ' . $Qtotal->getPageSetTotalRows(); getPageSetTotalRows() requires SQL_CALC_FOUND_ROWS to exist in the query and automatically retrieves the total rows using select found_rows() after the query has been executed. It is also possible to use fetchAll() however this method uses more server resources and is not recommended: $Qorders = $CLICSHOPPING_Db->prepare('select id from :table_orders where status = :status'); $Qorders->bindBool(':status', true); $Qorders->execute(); echo 'Total rows: ' . count($Qtotal->fetchAll()); Page Sets Returning a page set result is performed as: $Qorders = $CLICSHOPPING_Db->prepare('select SQL_CALC_FOUND_ROWS order_number, total_price From :table_orders where customer_id = :customer_id and status = :status order by id desc limit :page_set_offset, :page_set_max_results'); $Qorders->bindInt(':customer_id', 1); $Qorders->bindBool(':status', true); $Qorders->setPageSet(15); $Qorders->execute(); if ($Qorders->getPageSetTotalRows() > 0) { echo 'Orders'; while ($Qorders->fetch()) { echo 'Order #' . $Qorders->valueInt('order_number') . ': ' . $Qorders->valueDecimal('total_price'); } echo $Qorders->getPageSetLabel('Displaying <strong>{{listing_from}}</strong> to <strong>{{listing_to}}</strong> (of <strong>{{listing_total}}</strong> orders)'); echo $Qorders->getPageSetLinks(); } Parameters setPageSet($max_results, $page_set_keyword, $placeholder_offset, $placeholder_max_results) Parameter Value $max_results The number of results to show per page. $page_set_keyword The name of the parameter holding the current page value. Default: page $placeholder_offset The name of the binding placeholder used as the limit offset in the sql query. Default: page_set_offset $placeholder_max_results The name of the binding placeholder used as the limit row number in the sql query. Default: page_set_max_results The parameter name of the current page value is passed as the second parameter. The default value is page and the value is retrieved from $_GET['page'] if it exists. Caching Caching of select query result sets improves performance by storing the result of the query in a cache file and subsequently reading the cached data until the cache expiration time is reached. As soon as the cache expiration time is reached, the database is queried again and the cached information is refreshed with the new result set. $Qcfg = $CLICSHOPPING_Db->prepare('select key, value from :configuration'); $Qcfg->setCache('configuration'); $Qcfg->execute(); while ($Qcfg->fetch()) { echo $Qcfg->value('key') . ': ' . $Qcfg->value('value'); } Parameters setCache($key, $expire, $cache_empty_results) Parameter Value $key The name of the cache block to retrieve or save. $expire The time in minutes the cached data should be saved for. A value of 0 keeps the cached data indefinitly until it has been manually cleared. Default: 0 $cache_empty_results A boolean value to cache or not cache empty result sets. Default: false Shortcuts Shortcut functions wrap Db::prepare() into a simpler interface to help write code faster for simpler queries. Db::get() Db::get() can be used to retrieve rows from a simple query. $Qstates = $CLICSHOPPING_Db->get('states', [ 'id', 'title' ], [ 'country_id' => 1 ], 'title' ); while ($Qstates->fetch()) { echo $Qstates->value('title'); } Parameters Db::get($table, $fields, array $where, $order, $limit, $cache, array $options) Parameter Value $table One (string) or more tables (array) to retrieve the rows from. Aliases may be used as: ['countries as c', 'states as s'] Table names are automatically prefixed unless the prefix_tables option is set as false (see the $options parameter). $fields One (string) or more fields (array) to retrieve. Aliases may be used as: ['c.countries_id as id', 'c.countries_title as title'] $where Array containing keys and values matching the column name to the condition: ['id' => 1] $order One (string) or more fields (array) to sort by: ['title', 'c.date_added'] $limit An integer value to limit the number of rows to, or an array containing two integer values to limit the number of rows (second value) with an offset (first value): [1, 15] $cache An array consisting of the parameters (in order) sent to setCache(). $options An array containing the following options: ['prefix_tables' => true] A more complex multi-relationship query example can be performed as: $Qproducts = $CLICSHOPPING_Db->get([ 'products p', 'products_to_categories p2c' ], [ 'count(*) as total' ], [ 'p.products_id' => [ 'rel' => 'p2c.products_id' ], 'p.products_status' => '1', 'p2c.categories_id' => '1' ] ); $products_count = $Qproducts->valueInt('total'); Db::save() Db::save() can be used to insert or update data in a table. $result = $CLICSHOPPING_Db->save('states', [ 'title' => 'California' ], [ 'id' => 1 ] ); echo 'Affected rows: ' . $result; Parameters Db::save($table, array $data, array $where_condition, array $options) Parameter Value $table The table to save the data to. $data An associative key=>value array containing the data to save in the table. The array keys must match the table field names the array value should be saved in. $where_condition If no condition is passed, the data is inserted into the table as a new record. If an associative $key=>$value array is passed, it is used as the where condition of the query to update the data of an existing record. $options An array containing the following options: ['prefix_tables' => true] Db::delete() Db::delete() can be used to delete a single, multiple, or all records from a table. $result = $CLICSHOPPING_Db->delete('states', ['id' => 1 ]); echo 'Affected rows: ' . $result; Parameters Db::delete($table, array $where_condition, array $options) Parameter Value $table The table to delete the records from. $where_condition If no condition is passed, all records in the table are deleted. If an associative $key=>$value array is passed, it is used as the where condition of the query to delete the matching records. The array keys must match the table field names the array value is matched against. $options An array containing the following options: ['prefix_tables' => true] use Cache $Qcfg = $CLICSHOPPING_Db->prepare('select key, value from :configuration'); $Qcfg->setCache('configuration'); $Qcfg->execute(); while ($Qcfg->fetch()) { echo $Qcfg->value('key') . ': ' . $Qcfg->value('value'); } get information from Db $Qstates = $CLICSHOPPING_Db->get('states', [ 'id', 'title' ], [ 'country_id' => 1 ], 'title' ); while ($Qstates->fetch()) { echo $Qstates->value('title'); } $Qcfg = $CLICSHOPPING_Db->prepare('select key, value from :configuration'); $Qcfg->setCache('configuration'); $Qcfg->execute(); while ($Qcfg->fetch()) { echo $Qcfg->value('key') . ': ' . $Qcfg->value('value'); }
  11. Configuration Introduction The main installation configuration parameters are stored in the following locations: Type Location Global includes/ClicShopping/Conf/global.php Shop includes/ClicShopping/Sites/Shop/site_conf.php Shop includes/ClicShopping/Sites/ClicShoppingAdmin/site_conf.php The global configuration file and all site configuration files are automatically loaded into their own groups when the framework is initialized. The global configuration file is loaded into a 'global' group, and the site configuration files are loaded into their own Site group (eg, 'ClicShoppingAdmin', and 'Shop'). Reading a configuration value is first attempted at the Site level, and if the configuration key does not exist, the global value is returned. A Site level configuration parameter has priority over a global level parameter if a global level configuration parameter is also defined. Custom Configuration Files It's possible to create custom configuration files that have priority over the values from the core configuration files. Custom configuration files can be stored in the following locations: Type Location Global includes/ClicShopping/Custom/Conf/global.php Per-Site includes/ClicShopping/Custom/Sites/SITE/site_conf.php Configuration File Format The format of the configuration parameters are stored in a "ini" style format in a PHP file that is assigned to a $ini PHP variable. This style of configuration was chosen over a plain text .ini file to prevent configuration parameters being read in cases of the configuration files being publicly accessible through the web server. An example format for the global configuration file is: <?php $ini = <<<EOD db_server = "localhost" db_server_username = "dbuser" db_server_password = "dbpass" db_database = "my_db_name" db_table_prefix = "clic_" store_sessions = "MySQL" time_zone = "Europe/Berlin" EOD; An example of a Site configuration file is: <?php $ini = <<<EOD dir_root = "/www/html/" http_server = "https://demo.shop" http_path = "/" http_images_path = "images/" http_cookie_domain = ".clicshopping.shop" http_cookie_path = "/" EOD; External Configuration Files External configuration files can be loaded using the following code: use ClicShopping\OM\CLICSHOPPING; CLICSHOPPING::loadConfigFile($path_of_file, 'ext_group'); This would load the configuration parameters of $path_of_file to the 'ext_group' configuration group. It is important that the ini format is stored as a string to the $ini PHP variable otherwise the configuration parameters can not be parsed. Retrieving Configuration Parameters Configuration parameters can be retrieved using CLICSHOPPING::getConfig(): use ClicShopping\OM\CLICSHOPPING; $value = CLICSHOPPING::getConfig('cfg_name'); In this example, the cfg_name configuration parameter from the current Site group is returned. If the current Site group does not contain the configuration parameter, the global group value is returned. It's possible to define which group the configuration parameter should be loaded from by defining the group name: use ClicShopping\OM\CLICSHOPPING; $value = CLICSHOPPING::getConfig('cfg_name', 'ext_group'); This would load the cfg_name configuration parameter from the ext_group group. The following can be used to first see if a configuration parameter exists: use ClicShopping\OM\CLICSHOPPING; if (CLICSHOPPING::configExists('cfg_name')) { .... } This will check if cfg_name exists in the current Site group or the global group. Checking to see if a configuration parameter exists in a specific group is performed as follows: use ClicShopping\OM\CLICSHOPPING; if (CLICSHOPPING::configExists('cfg_name', 'ext_group')) { .... } Please note that if the configuration parameter does not exist in the specified group, a check is also performed in the global group. Setting Configuration Parameters Runtime configuration parameters can be set as follows: use ClicShopping\OM\CLICSHOPPING; $value = true; CLICSHOPPING::setConfig('is_true', $value, 'ext_group'); If no group is specified in the third parameter, the configuration parameter would be set in the global group. This function does not save the configuration parameter to the configuration file - it only sets a runtime configuration parameter value.
  12. ClicShopping\OM is a framework utilizing new features in PHP to improve the performance, security, and modularity of the codebase. Taking advantage of namespaces and autoloading, it is now even easier to add new features and extend existing features without the need to edit core source code files. The base framework is located in the includes/ClicShopping directory: Framework Namespace Location Core ClicShopping\OM includes/ClicShopping/OM Sites ClicShopping\Sites includes/ClicShopping/Sites Apps ClicShopping\Apps includes/ClicShopping/Apps Custom ClicShopping\Custom includes/ClicShopping/Custom Namespaces/Autoloader The framework is built utilizing the PSR-4 standard for autoloading classes from matching namespaces and file paths. Classes are automatically loaded on demand and don't need to be included/required manually. The base namespace the autoloader watches for is ClicShopping\ and loads the class files located in the includes/ClicShopping/ directory. Examples Class File Location ClicShopping\OM\CLICSHOPPING includes/ClicShopping/OM/CLICSHOPPING.php ClicShopping\OM\Db includes/ClicShopping/OM/Db.php ClicShopping\OM\Registry includes/ClicShopping/OM/Registry.php ClicShopping\Sites\Shop\Shop includes/ClicShopping/Sites/Shop/Shop.php ClicShopping\Apps\VENDOR\APP\APP includes/ClicShopping/Apps/VENDOR/APP/APP.php Classes in the framework must declare their namespace as the first PHP code in the file. Examples namespace CLICSHOPPING\OM; class NewClass { .... } The full namespace to the above example would be: ClicShopping\OM\NewClass and the location of the file would be: includes/ClicShopping/OM/NewClass.php For another class to be able to load ClicShopping\OM\NewClass automatically, it needs to be declared with PHP's use keyword after the namespace of the class and before any other PHP code. Examples namespace ClicShopping\OM; use ClicShopping\OM\NewClass; class AnotherNewClass { public function __construct() { $NewClass = new NewClass(); } } The framework autoloader (ClicShopping\OM\CLICSHOPPING::autoload()) is registered as an autoloader in includes/application_top.php and is automatically initialized in all main PHP files that include the application_top.php file. Template files do not need to have a namespace set, but still need to reference framework classes that it uses: Examples use ClicShopping\OM\HTML; echo HTML::outputProtected('Hello World!'); More information about namespaces can be found at the PHP Namespace documentation page. Sites Sites are registered in the framework to initialize and apply environment parameters specific to that site. The available sites in the core are: Site Controller Shop (default) ClicShopping\Sites\Shop\Shop Admin ClicShopping\Sites\ClicShoppingAdmin\Admin Sites are registered and retrieved as follows: use ClicShopping\OM\CLICSHOPPING; CLICSHOPPING::initialize(); CLICSHOPPING::loadSite('Shop'); $site = CLICSHOPPING::getSite(); Custom Directory To customize a core source file, copy it to this directory matching the directory structure of the original file. For example, - to make custom changes to ClicShopping/OM/Session/File.php - copy the complete file to ClicShopping/Custom/Session/File.php and perform your changes to this new file. Notes Although the custom class is copied to a Custom directory, it must retain the original Core namespace. Due to this, copied classes cannot extend the original class in the Core namespace. ClicShopping\Custom\Conf Configuration setting ClicShopping\Custom\Sites\Shop (default) Shop classes ClicShopping\Custom\OM OM classes ClicShopping\Custom\Schema Database file installation Apps Apps are self-contained packages that add new or extend existing features through modules and hooks. Apps reside in their own directory and do not need to edit core source code files. Apps are located in the following directory: Namespace Location ClicShopping\Apps\VENDOR\APP includes/ClicShopping/Apps/VENDOR/APP Apps also have a public directory for public accessible files such as stylesheets, javascript, and images, located at: public/Apps/VENDOR/APP More information is available in the Apps chapter. Service Services are portions of the online store that do not directly relate to the customer purchasing a product, but can be helpful in setting up the store. Services are available in Shop and ClicShoppingAdmin. it can use everywhere inside the site. Example Service for the mail namespace ClicShopping\Service\Shop; use ClicShopping\OM\Registry; use ClicShopping\OM\Mail as MailClass; class Mail implements \ClicShopping\OM\ServiceInterface { public static function start() { if (is_file(CLICSHOPPING_BASE_DIR . 'OM/Mail.php')) { Registry::set('Mail', new MailClass()); return true; } else { return false; } } public static function stop() { return true; } } How to call inside a file : $CLICSHOPPING_Mail = Registry::get('Mail');
  • Create New...

Important Information

By using this site, you agree to our Terms of Use