Showing posts with label opencart. Show all posts
Showing posts with label opencart. Show all posts

Monday, November 14, 2016

Why We Love OpenCart

1. OpenCart is Free

2. Open-Source, Customizable and Flexible

3. Responsive Design

4. Free and Paid Functionality Extensions

5. SEO Ready

6. Analytics, Statistics and Advanced Data Tracking

7. Secure Payment and Shipping Methods

8. Multi-Store and Multi-Lingual Capabilities

9. Coupons, Specials, Reward Points and Gift Vouchers

10. Large User Base and Community


Thursday, November 10, 2016

vQmod Scripts and Syntax


Scripting

The Golden Rules

First things to set in your mind...
  • The <search> tag can only be a single line, though doesn't have to be a whole line, as partial matches work too. You should learn how to use the offset attribute to properly encompass all needed lines, but that doesn't mean you should encompass many lines. Instead of trying to include many lines from top down, try starting at the bottom and finding lines going up.
  • Less is more! Whenever possible, try to match the smallest, yet still unique part of the code. That will improve the chances of being more future-resistant and avoid breaking other mods that may have changes close to yours.
  • Pay attention to all the attribute options for each tag. There is a lot of power that is overlooked by people skimming over the syntax

How to make vQmod Scripts

vQmod currently uses an xml formatted parser by default but other parsers can be created in the future as well.
A simple replace script example looks like this:
    <?xml version="1.0" encoding="UTF-8"?>
    <modification
                xmlns="https://github.com/vqmod/vqmod"
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xsi:schemaLocation="https://github.com/vqmod/vqmod https://raw.githubusercontent.com/vqmod/vqmod/master/vqmod.xsd"
                >
        <id>Replace 123 with ABC</id>
        <version>1.0.0</version>
        <vqmver>2.5.0</vqmver>
        <author>qphoria</author>

        <file name="relative/path/myfile.php">
            <operation>
                <search position="replace"><![CDATA[
                $var = '123';
                ]]></search>

                <add><![CDATA[
                $var = 'ABC';
                ]]></add>
            </operation>
        </file> 
    </modification>
This script simply changes the value of a variable of "myfile.php" from "123" to "ABC" before it gets included.

Syntax

vQmod supports a number of parameters:
modification
  • This is the highest level of the file and there can only be one
modification / id
  • This is the name and description of the mod.
  • Format: Free form text. (Informational)
modification / version
  • This is the version of the mod.
  • Format: Number and Decimal (1.0.0) (Informational)
modification / vqmver
  • This is the minimum required version of VirtualQMod needed for the script to work.
  • Format: Number and Decimal (1.0.0) (Informational)
  • A required="true" attribute can be optionally set to disable the script if it doesn't meet the required version (Added from 2.4.0)
modification / author
  • This is the author of the mod.
  • Format: Free form text (Informational)
modification / file
  • This is the name of the file to modify
  • Requires attribute "name" as relative filename to the location of the main index.php file (e.g. catalog/controller/product/product.php). Can be delimited with commas to apply to multiple files at once (2.3.0 +) Name attribute supports a wildcard (*) character for dynamic path building. Each wildcard is limited to a single directory level.
     - catalog/view/theme/*/template/product/product.tpl
     - catalog/view/theme/*/*/product/product.tpl
     - etc
  • There can be multiple file tags in a single xml file. Each file can have its own set of operations
  • Optional attribute "path" can be used to prefix file name's to avoid repetition. This is simply prepended to the file names and no validation is attempted (2.3.0 +)
  • Optional attribute "error" set to log|skip|abort
    • skip means it will simply ignore this file.
    • log is the same as skip, but logs the error. (default)
    • abort means to log the error and cancel the remaining operations in that particular xml script. It does not revert changes to other files already made in that script and doesn't stop other xml files.
    • Wildcard paths will ignore the "error" attribute completely
modification / file / operation
  • This is the wrapper of the actual operation occurring.
  • There can be multiple operations to the same file tag.
  • Optional attribute "info" suggested. May be used by vQmod/vQmod Manager for OC in the future but at present isn't used. This is however ideal for making files easier to read
  • Optional attribute "error" set to skip|log|abort
    • skip means all other operations will be applied even if one cannot. There will be no error in the log.
    • log is the same as skip, but logs the error.
    • abort means to log the error and revert to the original source. (default)
modification / file / operation / ignoreif
  • This allows for a search to be made on a file. This search works across multiple lines not just single lines. This tag is optional and if the search is found, the operation is skipped
    • Optional attribute "regex' set to true|false. Format of data inside tag then requires delimiters for regex as it uses the standard preg_match method for php. This attribute defaults to false
modification / file / operation / search
  • This is the first required step of the operation.
  • Can only search single lines, both fully and partially. But offset and index attributes will assist.
  • Automatically trims whitespace and linebreaks
  • One <search> tag per <operation> tag
  • Use CDATA tags to wrap code.
  • Required attribute "position" set to before|after|replace|top|bottom|all|ibefore|iafter.
    • replace will replace the data in the search tag with the data in the add tag. (default)
    • before will insert the add data before the search data
    • after will insert the add data after the search data
    • top will insert the add data at the top of the file. The search data is ignored.
    • bottom will insert the add data at the bottom of the file. The search data is ignored.
    • all will completely replace all the code in the file with the add data. The search data is ignored. Deprecated as of 2.4.0
    • ibefore will insert the code before the search inline instead of the line before
    • iafter will insert the code afterthe search inline instead of the line before
  • Optional attribute "offset" to work with the position
    • if the search position is before and offset 3 it will put the add data before the line, 3 lines above the searched line
    • if the search position is after and offset 3 it will put the add data after the line, 3 lines below the searched line
    • if the search position is replace and offset 3 it will remove the code from the search line and the next 3 lines and replace it with the add data
    • if the search position is top and offset 3 it will put the code before the line, 3 lines below the top of the file
    • if the search position is bottom and offset 3 it will put the code after the line, 3 lines above the bottom of the file
  • Optional attribute "index" for specifying which instances of a search tag should be acted on
    • If the search string is "echo" and there are 5 echos in the file, but only want to replace the 1st and 3rd, use index="1,3"
    • Comma delimited for multiple instances starting with "1"
    • Leave out or set to FALSE to replace all instances. (default)
  • Optional attribute "regex" for specifying whether or not to search a regex pattern.
    • If true, the search data should be a valid regex pattern
    • Leave out or set to FALSE to use normal string search (default)
    • Does not apply to ibefore and iafter
  • Optional attribute "trim" set to true|false
    • true will trim away whitespace and linebreaks.
    • leave out or set to true to trim. (default is true)
modification / file / operation / add
  • This is the second required step of the operation.
  • Can be multiple lines
  • One <add> tag per <operation> tag.
  • Location of added data depends on the position attribute of the search command.
  • Use CDATA tags to wrap code.
  • NEW IN 2.6.0<add> tag now supports all the search attributes.
  • Attributes in the <add> tag will override attributes in the <search> tag.
  • Optional attribute "position" set to before|after|replace|top|bottom|ibefore|iafter.
    • replace will replace the data in the search tag with the data in the add tag. (default)
    • before will insert the add data before the search data
    • after will insert the add data after the search data
    • top will insert the add data at the top of the file. The search data is ignored.
    • bottom will insert the add data at the bottom of the file. The search data is ignored.
    • ibefore will insert the code before the search inline instead of the line before
    • iafter will insert the code afterthe search inline instead of the line before
  • Optional attribute "offset" to work with the position
    • if the search position is before and offset 3 it will put the add data before the line, 3 lines above the searched line
    • if the search position is after and offset 3 it will put the add data after the line, 3 lines below the searched line
    • if the search position is replace and offset 3 it will remove the code from the search line and the next 3 lines and replace it with the add data
    • if the search position is top and offset 3 it will put the code before the line, 3 lines below the top of the file
    • if the search position is bottom and offset 3 it will put the code after the line, 3 lines above the bottom of the file
  • Optional attribute "index" for specifying which instances of a search tag should be acted on
    • If the search string is "echo" and there are 5 echos in the file, but only want to replace the 1st and 3rd, use index="1,3"
    • Comma delimited for multiple instances starting with "1"
    • Leave out or set to FALSE to replace all instances. (default)
  • Optional attribute "regex" for specifying whether or not to search a regex pattern.
    • If true, the search data should be a valid regex pattern
    • Leave out or set to FALSE to use normal string search (default)
    • Does not apply to ibefore and iafter
  • Optional attribute "trim" set to true|false
    • true will trim away whitespace and linebreaks.
    • leave out or set to true to trim. (default is true)
<![CDATA[ ]]>
  • These are called CDATA tags and they are used by xml to specify that the data between should not be evaluated. It's recommended you always use these for data between the and operation tags

Tuesday, November 8, 2016

About vQmod

What is vQmod?

vQmod™ (aka virtual Quick mod) gives the ability to create modification "scripts" that override the code during execution time. It intercepts the "include()" and "require()" functionality of php and substitutes the modified code in place of the original.

How does it work?

Instead of modifying actual files to add custom modifications, source files are parsed "on-the-fly" right before any of the follow functions are called:
  • include()
  • include_once()
  • require()
  • require_once()
The source is then cloned to a temp file and modifications read from an external script file are made to that temp file. The temp file is then substituted for the real file in the include path. Now the modification is in place while the original file has not actually been altered. This means no code is ever altered from the original. To uninstall a script, simply remove the xml script file and you are back to the original. Simple!

Other Details

  • The vQmod class is currently written in PHP and the script files are xml based, but the concept could be theoretically be ported to any language and parsers could be created for any format.
  • Currently, OpenCart is the only fully tested and working platform that vQmod works with, but this is a concept that can work for other projects and platforms that are controller-based.

Limitations

vQmod relies on a controller based system that has a series of files that are linked and extended. There are some files that cannot be used with vQmod.
  • index.php - since this is the main file of the site, it has to load vQmod first for it to work on other pages. So you can't put the cart in front of the horse.
  • Standalone files - Files that are just standalone and don't extend or have no hierarchy will not work with vQmod. vQmod works by intercepting the "include" functions. So if file isn't being included or required, then it cannot be vQmodded
  • css & js files - These files are rendered at the browser level, not at the server level, so vQmod has no effect on these. You can, however, create new files and use vQmod to alter the tpl files to point to these new css/js files. Or you can put

Thursday, October 27, 2016

System Requirements OpenCart 2.3.0.2

System / Server requirements

OpenCart requires certain technical requirements to be met for the store to operate properly. First, a web server must be created to make the OpenCart store publicly available on the web. Domain names and hosting services can easily be purchased for an affordable price.
When selecting a hosting service, you should check to see that these server requirements are provided and installed on their web servers:
These extensions must be enabled for OpenCart to install properly on the web server.
  • Web Server (Apache suggested)
  • PHP 5.3+(1.5.x at least 5.2+)
  • Database (MySQLi suggested)
Required PHP libraries / modules
  • Curl
  • ZIP
  • Zlib
  • GD Library
  • Mcrypt
  • Mbstrings
  • Xml
The above PHP extensions should be available by almost all hosting providers, during the install processa it will check you have them all enabled. You should contact your hosting provider if one is missing.

Wednesday, October 26, 2016

How to cancel credit in opencart

Suppose it may happen, customer purchase something from your website but after successful transaction, you come to know that particular product is not in stock.

Now you have to give refund to that customer as a credit amount so customer can use that amount in future.

For that do following:

1.Go to customers section
2.go to that particular customer
3.There, you will see “Transactions” tab. Press it and enter amount and description. Click Add Transaction.
4.That’s it. Now your customer get credit and mail also send to that customer (Tested in OP 2)