Search

QDapp.net @ WordPress

Blog site for QDapp.net

Category

How-to

How to add bcc function to OpenCart email class

Locate file to edit

OpenCart email class is defined in mail.php: \system\library\mail.php
mail.php may be cached: \system\library\cache\mail.php
If you have vqmod installed, it may be cached here \vqmod\vqcache\vq2-system_library_mail.php

Codes

  1. After “protected $to;” add variable

    protected $bcc;

  2. After “public function setTo($to)” function, add bcc function

    public function setBcc($bcc) {
    $this->bcc = $bcc;
    }

  3. Modify “public function send()” function
    You can add after “if ($this->protocol != ‘mail’) {” statement
    Or you can add to any where within setting “$header” variable section

    if ($this->bcc) {
    $header .= ‘Bcc: ‘ . $this->bcc . ‘\n’
    }

Usage

For example, I was trying to add BCC to admin email in an OpenCart site whenever a user tries to re-set his/her user — See Customize OpenCart Forgotten Password Email
So, I would modify codes on this file \catalog\controller\account\forgotten.php by adding a line of code after “$mail->setTo…”

$mail->setBcc(“myemail@myemailprovider.com”);

Customize OpenCart Forgotten Password Email

To edit text on forgotten email page – route=account/forgotten

Modify file: \catalog\language\english\account\forgotten.php

To edit forgotten email sends to customer

  • Text: \catalog\language\english\account\forgotten.php
  • Codes: \catalog\controller\account\forgotten.php

How to create, read and update Application Settings (.NET)

Create Application Settings

In Visual Studio, right click on your application project => Properties => Settings
OR Menu => Project => [Your project name] Properties… => Settings

There are 2 scopes:
– User: Can set at design time and update at run time.
– Application: Can only set at design time and can’t be modified at run time.

Read Application Settings

var yourUserSettingValue = Properties.Settings.Default.YOUR_USER_SETTING_NAME;
var yourApplicationSettingValue = Properties.Settings.Default.YOUR_APPLICATION_SETTING_NAME;

Update Application Settings (Only apply to User scope)

Properties.Settings.Default.YOUR_USER_SETTING_NAME = NEW_VALUE;
Properties.Settings.Default.Save();

How to Read Application Settings from the Web.config File

Create Web.config

If you web site doesn’t have Web.config file, you can create one

  • Using Visual Studio: Right click on your web site > Add > Add New Item… > Web Configuration File > Web.config
  • Manually: Create a text file and change name to Web.config at your web site root folder

Add application settings (key-value pair)

Open Web.config

<?xml version=”1.0″?>
<configuration>

<appSettings>
<add key=”KeyName1″ value=”KeyValue2″/>
<add key=”KeyName2″ value=”KeyValue2″/>

</appSettings>
</configuration>

Read application settings

  1. Add:
    using System.Web.Configuration;
  2. Codes:
    var key1 = WebConfigurationManager.AppSettings[“KeyName1”];
    var key2 = WebConfigurationManager.AppSettings[“KeyValue2”];

 

 

How to Add Custom Field to Contact Form in Contact Us Page in OpenCart 2.0

In OpenCart 2.0 default Contact Us page (/index.php?route=information/contact) – Contact Form has only 3 fields: Your Name, E-Mail Address, and Enquiry

To add custom fields to Contact Form, you can

  1. Buy an extension (as of 5/9/2015, it seems that I can’t find one that modify directly Contact Us form) – UPDATE as of 4/25/2016, there are quite some extensions available.
  2. Do it yourself: To do it yourself you can follow this tutorial link or follow instructions below to add a Telephone is the form (if you want to add more fields, just add more similar codes)

To add custom Telephone field to “Contact Form” in OpenCart 2.0, you would need to edit 3 files:

  1. \catalog\language\english\information\contact.php
  2. \catalog\controller\information\contact.php
  3. \catalog\view\theme[YourThemeName]\template\information\contact.tpl

[YourThemeName] = Whatever theme that you selected for your store, default is “default” (You can verify or set it here: /Admin => Systems => Settings => Select your store and click Edit => Store tab => Default Layout)

1. Edit language file: \catalog\language\english\information\contact.php

a. Under line:

$_['entry_email']    = 'E-Mail Address';

Add code:

$_['entry_phone']     = 'Telephone';

b. Under line

$_['error_email']    = 'E-Mail Address does not appear to be valid!';

Add code:

$_['error_phone']    = 'Telephone is required!';

2. Edit control file: \catalog\controller\information\contact.php

a. Under code:

$data['entry_email'] = $this->language->get('entry_email');

Add code:

$data['entry_phone'] = $this->language->get('entry_phone');

b. Under code

if (isset($this->error['email'])) {
        $data['error_email'] = $this->error['email'];
    } else {
        $data['error_email'] = '';
    }

Add code

if (isset($this->error['phone'])) {
        $data['error_phone'] = $this->error['phone'];
    } else {
        $data['error_phone'] = '';
    }

c. Under code:

if (!preg_match('/^[^\@]+@.*.[a-z]{2,15}$/i', $this->request->post['email'])) {
        $this->error['email'] = $this->language->get('error_email');
    }

Add code:

if ((utf8_strlen($this->request->post['phone']) < 1)) {
        $this->error['phone'] = $this->language->get('error_phone');
    }

d. FIND code

$mail->setText($this->request->post['enquiry']);

UPDATE code to

$mail->setText($this->request->post['enquiry'] . $mail->newline . 'Telephone: ' . $this->request->post['phone']);

e. Under code: 1/4/2016 NEW CODES ADDED TO FIX Undefined variable: phone

if (isset($this->request->post['email'])) {
   $data['email'] = $this->request->post['email'];
} else {
   $data['email'] = $this->customer->getEmail();
}

Add code:

if (isset($this->request->post['phone'])) {
   $data['phone'] = $this->request->post['phone'];
} else {
   $data['phone'] = '';
}

3. Edit template file: \catalog\view\theme[YourThemeName]\template\information\contact.tpl

a. Under line:

Will update this section… WordPress auto remove my php codes even thought I pasted as text only or use <pre> tag still not working


After update above 3 files, just upload to your server and test. Good luck!

I posted an answer in stackoverflow site

How to Change Default Product Sorting from Default Sort to Product Name in OpenCart 2.0

If you want to change default product sorting to sort by product name,

Locate file

\system\modification\catalog\controller\product\category.php

Search for

$sort = 'p.sort_order';

Replace with

$sort = 'pd.name';

You can also change default sorting to

Price

$sort = 'p.price';

Model

$sort = 'p.model';

How to Fix Date Added Format Issue in Email Order of OpenCart Version 2.0.2.0

OpenCart version 2.0.2.0 has a language pull bug with Date Added in order confirmation email.

Incorrect date format would displayed similar to below

Date Added: 25pm30UTC_f2015Sat, 25 Apr 2015 15:40:36 +000004pm30_36032015Sat, 25 Apr 2015 15:40:36 +000030

To fix it, update OpenCart php file

catalog\model\checkout\order.php

Replace

$language->load('default');

With

$language->load($order_info['language_directory']);

Make sure you update both lines 401 and 803 (or near there) – One for customer email and for admin email

How to Enable PHP cURL and Mcrypt – Required Components When Install OpenCart

cURL

Try to run these commands in Termial

sudo apt-get install php5-curl

sudo service apache2 restart

If still not working, try to enable it in php.ini file (I use gedit, but you can use any text editor)

sudo gedit /etc/php5/apache2/php.ini

After php.ini opened, search for cURL,

If you found a line with ;extension=php_curl.dll, then remove semi-colon ; to become extension=php_curl.dll

if no line like above, then add one

extension=php_curl.dll

Save and restart Apache

sudo service apache2 restart


Mcrypt

Try to run these commands in Terminal

sudo apt-get install php5-mcrypt
sudo ln -s /etc/php5/conf.d/mcrypt.ini /etc/php5/mods-available
sudo php5enmod mcrypt
sudo service apache2 restart

Keep running next command if other commands already ran/exist

For more information about How To Install OpenCart on an Ubuntu 12.04 VPS, visit https://www.digitalocean.com/community/tutorials/how-to-install-opencart-on-an-ubuntu-12-04-vps

How to adjust banner “Home Page Slideshow” OpenCart 2.0

To adjust speed or change settings of the “Home Page Slideshow” OpenCart 2.0

  1. FTP or use file manager to access and modify slideshow.tpl file where location is /catalog/view/theme/[YOUR THEME]/template/module/slideshow.tpl
  2. Open slideshow.tpl file and find autoPlay, to adjust the speed update the default value from 3000 to any number you like, 1000 = 1 second
  3. To turn off the auto slide, set autoPlay: false
  4. To see more features, visit Owl Carousel slider plugin site http://owlgraphic.com/owlcarousel/ where you can learn more about this plugin.

Sample codes

Before update

$('#slideshow').owlCarousel({
	items: 6,
	autoPlay: 3000,
	singleItem: true,
	navigation: true,
	navigationText: ['', ''],
	pagination: true
});

After update: turn off auto slider

$('#slideshow').owlCarousel({
	items: 6,
	autoPlay: false,
	singleItem: true,
	navigation: true,
	navigationText: ['', ''],
	pagination: true
});

Create a free website or blog at WordPress.com.

Up ↑