OCMOD searching whem i have line breaks or undefined whitespaces - regex

im trying to make a OCmod for opencart 2.0.3.1
and when i try to find in catalog/view/theme/*/template/common/header.tpl
these two parts of html code the script dont find anything in error log its says NOT FOUND.
the first search is that
<search>
<![CDATA[
<?php } ?>
<?php } ?>
]]>
</search>
and the seccond serach if for that
</ul>
</div>
</nav>
both of this searchs not find any thing but i copied and pasted from the original file.
some one can help me to improve this serach whit regex or tell me how ocmod works to serach that?

Here is the sample OCMod code to do more better search in your opencart 2.x version.
<file path="catalog/view/theme/*/template/common/header.tpl">
<operation>
<search><![CDATA[}}]]></search>
<add position="after"><![CDATA[This is test ocmod]]></add>
</operation>
</file>
This is test ocmod text display after } }
Try this kind of code in your ocmod.

Related

Opencart 3 Add Additional Delivery Detail

I need to add additional delivery option in the delivery detail of Opencart 3's checkout page.
I found the file in > catalog/view/theme/default/template/checkout/shipping_address.twig
I tried modify but not visual change in the checkout page.
Can anyone guide me to the correct file ?
Note: currently im using default template.
Create a file, named "install.xml" and then zip it. Then install it as module from extension upload. And then refresh cache from "Modifications".
<?xml version="1.0" encoding="utf-8"?>
<modification>
<name>Additional Delivery Detail</name>
<code>delivery</code>
<version>1.0</version>
<author>white coffeee</author>
<link></link>
<file path="catalog/view/theme/default/template/checkout/shipping_address.twig">
<operation>
<search><![CDATA[ **CODE TO BE SEARCHED** ]></search>
<add position="after"><![CDATA[
**CODE TO BE ADDED**
]]></add>
</operation>
</file>
</modification>

how to display future products in opencart

products in open cart script doesn't show up in front end page when i add product and set the date to the future
am trying to display future products S i want to know how can i do that is there anyway i can do that,i do search a lot for answer to that question but all i found is xml file need vqmod system but it's not working too . so please guys am trying to display future products on homepage
here's then answer which didn't work
<modification>
<id><![CDATA[Products with future available date become able to show in store and be purchased]]></id>
<version><![CDATA[1.0.0]]></version>
<vqmver><![CDATA[2.0.0]]></vqmver>
<author><![CDATA[angeloop]]></author>
<file name="catalog/model/catalog/product.php">
<operation>
<search position="after"><![CDATA['p.date_added']]></search>
<add><![CDATA[, 'p.date_available']]></add>
</operation>
<operation>
<search position="replace"><![CDATA[AND p.date_available <= NOW()]]> </search>
<add><![CDATA[]]></add>
</operation>
</file>
<file name="system/library/cart.php">
<operation>
<search position="replace"><![CDATA[AND p.date_available <= NOW()]]></search>
<add><![CDATA[]]></add>
</operation>
</file>
</modification>
I have created a module for it.
Go to the link below
Coming soon products module for OpenCart
Download the modules and set the modules which will show future products or coming soon products

Proper way to work using the real image of a product on OpenCart 2

I'm currently looking for the proper way to work on a theme using the real image of a product and not its thumbnail (identified as $thumb in the default theme).
I have found a abrupt trick by adding a line in the controller file:
$this->data['cover'] = $product_info['image'];
But does anybody have experienced a better method (eg with vqmod) to retrieve these real image data without changing controller content (for using in template pages, such as product.tpl or category.tpl for example)?
With help from members of OpenCart forum, I managed to find a functional solution (using vQmod).
It is thus require to create an .xml file placed in the vqmod/xml folder and containing, for example:
<?xml version="1.0" encoding="utf-8"?>
<modification>
<id>Recover Real Image</id>
<version></version>
<vqmver></vqmver>
<author></author>
<email></email>
<website></website>
<file name="catalog/controller/product/product.php">
<operation>
<search position="after"><![CDATA[
$data['points'] = $product_info['points'];
]]></search>
<add><![CDATA[
$data['picture'] = HTTP_SERVER.'/image/'.$product_info['image'];
]]></add>
</operation>
</file>
</modification>
If product image can not be found and assuming a <default.jpg> is put the root of the <image> folder, the <add> element can be replaced by:
if(empty($product_info['image'])){
$data['picture'] = HTTP_SERVER.'image/default.jpg';
}
else{
$data['picture'] = HTTP_SERVER.'image/'.$product_info['image'];
}
Other possible suggestions, by using:
OCmod can be found here
Image Autosize extension can be found here

Correct implementation of Google Tag Manager in OpenCart

I need some advice in placing Google Tag Manager (assuming the API is already written) in OpenCart. I've thought of loading it straight from header.tpl, however I want to know what the cleanest implementation would be.
I've found this solution to be optimal for me. Tested and it works. You will need Vqmods installed (https://github.com/vqmod/vqmod/wiki).
I used an edited version of this script (http://www.opencart.com/index.php?route=extension/extension/info&extension_id=18200). Basically, what you want to do is replace the search query so that it matches your body tag's class.
Keep in mind that you should check your header.tpl to make sure you place the GTM code right at the beginning of your body tag.
Finally, my edited xml:
<?xml version="1.0" encoding="UTF-8"?>
<modification>
<id><![CDATA[Google Tag Manager]]></id>
<version><![CDATA[1.0]]></version>
<vqmver><![CDATA[]]></vqmver>
<author><![CDATA[hany.mesbah#gadalla.com]]></author>
<file name="catalog/view/theme/*/template/common/header.tpl">
<operation error="log">
<search position="after"><![CDATA[<body class="fs<?php echo $themeConfig['fontsize'];?> <?php echo $helper->getPageClass();?> <?php echo $helper->getParam('body_pattern','');?>">]]></search>
<add><![CDATA[your GTM code snippet]]></add>
</operation>
</file>
</modification>

OCMOD Implementation OpenCart 2.0

Have anybody have implemented OCMOD for plugin development in opencart 2.0 ?
Do we need to install VQMOD to execute OCMOD?
I found https://github.com/opencart/opencart/wiki/Modification-System but still
unable to get clear idea.
Any help would be really appreciated.
Thanks
No, You need not to install VQMOD to execute OCMOD. OCMOD works independently.
You have to create ocmod xml file with ".ocmod.xml" extension, then you can upload that file using "Extension Installer" from admin panel of opencart.
You have to clear and refresh the modification cache to update the system and make the extension work.
You can clear and refresh by top right buttons on Extension > Modification page in admin panel.
OCMod is essentially a poor mans VQMod. there are a number of features missing that aren't/won't be in it that are in VQMod, the biggest of which is being able to add content before/after a certain line match and as such would really recommend just sticking with VQMod which works just fine (version 2.5 and above)
I've used ocmod and released a few free oc extensions.
VQMOD and OCMOD are two separate things (as already commented).
Both will not interfere with each other.
You can load ocmod .ocmod.xml scripts from the administration panel (extensions and modifications).
A suggestion is to not invest too much work right now since ocmod is still a bit limited and probably is going to change in the near future.
A few persons are suggesting to implement quite all the functionalities of vqmod and the whole system/methods can change in the near future
https://github.com/opencart/opencart/issues/2045
I personally prefer vqmod since the development can be faster and you can edit the xml on the fly and refresh the browser.
I've done 3 different vqmods in around one hour while in ocmod i've spent the same time only to upload/edit/remove the (3) modifications with different tags (required by ocmod).
Caching in ocmod seems to be slower on my system (with a modification on a lot of of php files) and sometimes the modifications are not appearing (in the browser) immediately. I don't know if it's a problem on my specific system.
The logs of ocmod are not giving too much informations in case of errors.
I've been trying to get an OCMOD installed today on version 2.0.1.0 of OpenCart.
Did not figure it out and the forums and documentation did not provide adequate help.
While the install may be broken or my environment is bugging it, VQMODs and OCMODs are separate entities and don't depend on one another.
For example, VQMOD uses XML files to store the modifications, and builds a cache with the modified core files.
OCMOD stores the code changes in the database directly without saving the uploaded XML, and seems to build a cache from there (I hope it does the cache part, haven't found proof yet).
The install code for the OCMOD is found in \admin\controller\extension\installer.php
public function xml() {
So you don't need to mess with VQMOD to get OCMOD working unless you have old VQMODs and don't want to reupload them.
I tried OCMOD now, it's pretty easy if you know what files you need to change and how you want to change them. You can find some official documentation here and a good regexp tester here.
If you click Extensions / Modifications / Add in admin you can just paste your XML, select Activated, Save and then Update modifications, then click Log to check log messages, then check your modified files below the directory system/modifications.
Something to remember is to delete your modification and add it as a new one when changing it, it seems that just updating it isn't enough to reload it's XML.
Here is an example module I made to remove wish-list buttons
<?xml version="1.0" encoding="utf-8"?>
<modification>
<name>Remove wishlist buttons</name>
<code>cjohanssonremovewishlistbutons</code>
<version>1.0</version>
<author>Christian Johansson</author>
<link></link>
<file path="catalog/view/theme/default/template/product/product.tpl">
<operation>
<search trim="true">
<![CDATA[<button type="button" data-toggle="tooltip" class="btn btn-default" title="<?php echo $button_wishlist; ?>" onclick="wishlist.add('<?php echo $product_id; ?>');"><i style="color:<?php echo html_entity_decode($config->get('ekometcss_css_wishlist_color'), ENT_QUOTES, 'UTF-8'); ?>;" <i class="<?php global $config; echo $config->get('ekometcss_custom_icons_wishlist') ? 'fa fa-' . $config->get('ekometcss_custom_icons_wishlist') : 'fa fa-star'; ?>"></i></button>]]>
</search>
<add position="replace">
<![CDATA[]]>
</add>
</operation>
</file>
<file path="catalog/view/theme/default/template/module/*.tpl">
<operation>
<search trim="true">
<![CDATA[<button style="width: 80%;" type="button" class="cat-cart"]]>
</search>
<add position="replace">
<![CDATA[<button style="width: 100%;" type="button" class="cat-cart"]]>
</add>
</operation>
<operation>
<search trim="true">
<![CDATA[<button style="width: 20%;" type="button" class="cat-wishlist" data-toggle="tooltip" title="<?php echo $button_wishlist; ?>" onclick="wishlist.add('<?php echo $product['product_id']; ?>');"><i style="color:<?php echo html_entity_decode($config->get('ekometcss_css_wishlist_color'), ENT_QUOTES, 'UTF-8'); ?>;" <i class="<?php global $config; echo $config->get('ekometcss_custom_icons_wishlist') ? 'fa fa-' . $config->get('ekometcss_custom_icons_wishlist') : 'fa fa-star'; ?>"></i></button>]]>
</search>
<add position="replace">
<![CDATA[]]>
</add>
</operation>
</file>
<file path="catalog/view/theme/default/template/product/category.tpl">
<operation>
<search trim="true">
<![CDATA[<button style="width: 80%;" type="button" class="cat-cart"]]>
</search>
<add position="replace">
<![CDATA[<button style="width: 100%;" type="button" class="cat-cart"]]>
</add>
</operation>
<operation>
<search trim="true">
<![CDATA[<button style="width: 20%;" type="button" class="cat-wishlist" data-toggle="tooltip" title="<?php echo $button_wishlist; ?>" onclick="wishlist.add('<?php echo $product['product_id']; ?>');"><i style="color:<?php echo html_entity_decode($config->get('ekometcss_css_wishlist_color'), ENT_QUOTES, 'UTF-8'); ?>;" <i class="<?php global $config; echo $config->get('ekometcss_custom_icons_wishlist') ? 'fa fa-' . $config->get('ekometcss_custom_icons_wishlist') : 'fa fa-star'; ?>"></i></button>]]>
</search>
<add position="replace">
<![CDATA[]]>
</add>
</operation>
</file>
</modification>
Have anybody have implemented OCMOD for plugin development in opencart 2.0 ?
Ans: Yes
Do we need to install VQMOD to execute OCMOD?
Ans: No
OCMOD Folder structure like this for Opencart
-upload -admin...(if you have required)
-catalog..(if you have required)
- - - -
- install.xml
Zip these and named like this .ocmod.zip
Then You can able to install with Opencart Installer
No
VQMOD is seperated Plugin that depend on file system XML Files
OCMOD Depend on DB when you install new ocmod plugin it stored in modifications table