All posts by Jawad Rehman

 A Software Engineer having great experience with all the stages of SDLC including designing, developing, testing software's.  Result oriented, self driven, highly motivated, smart and hungry to learn new technologies, methodologies, strategies and processes.

Customer email address to success.tpl in OpenCart

It can be done using the following code;

/catalog/controller/checkout/success.php

$this->load->model(‘account/order’);
$order = $this->model_account_order->getOrder($this->session->data[‘order_id’]);
if($order) {
$this->data[’email’] = $order[’email’];
}

 

In your template /catalog/view/theme/your-theme-name/template/common/success.tpl you need to put

<?php if(!empty($email)) echo $email; ?>

Image path Opencart

Question
I’m editing this file header.tpl inside /template/common uploaded the image at : /catalog/view/theme/TEMPLATENAME/image and I need to add

Code:
<img src=”facebook.png”>
I tried Code:
<img src=”../image/facebook.png”>
and Code:
<img src=”../../image/facebook.png”>
but the image still doesn’t show. What’s the correct image path?

Answers
all files are served from index.php so (the root)therefore your image src would be:

Code:
<img src=”catalog/view/theme/TEMPLATENAME/image/facebook.png”>
unless you are using the image in a stylesheet, then it would be Code:
url(“../image/facebook.png”)
it worked!

Regular Expression Examples

1.

.

Any character

2.

\.
dot character

3.

+

One or more character

4.

*

Zero or more characters

5.

H.+H
Greedy

6.

H.+?H

Non greedy

7.

^
not and also used as beginning of string.

8.

$

End of string

9.

Numbers in the format [12345-1234]
[\d]{5}-[\d]{4}

10.

Numbers in format[12345-1234(optional])
^[\d]{5}(?:-[\d]{4})?$

11.

Email
\w+@\w+\.\w{1,3}
^.+?@.+\.[a-z]{2,4}$

12.

Repeating words (is is)
([a-z]+)\s+\1

13.

Date (day/month/year-12/04/2014)
(0[1-9]|1[0-2])\/(0[1-9]|[12][0-9]|3[0-1])\/([0-9]{4})

14.
Time (12:00 PM)

(1[0-2]|0?[1-9]):([0-5][0-9])\s([PA]M)

15.

IP
192.168.1.1
([0-9]{1,3}\.){3}[0-9]{1,3}

16.
URL

https://www.googe.com
http://www.googe.com
file://www.googe.com

(https?|ftp|file)://.+$

17.
file with image extension

^.+(jpg|gif|png)$

(^.+(jpg|gif|png)$)

18.
href=([“‘])([^”‘]+)([“‘])

<a href=”www.google.com” title=”this” >

19.

display:box;
box-shadow:1px 2px 3px black;
box-sizing:100% 100%;

^box-(shadow|sizing)[^;]+
^box-(shadow|sizing).+$

20.

Negative look behind
display:box;box-shadow:1px 2px 3px black;box-sizing:100% 100%;
(?<!:)box[^;]+

21.

postive look ahead

jawad@gmail.com
ali@yahoo.com

@.+(?=\.[a-z]{2,4})

22.

Negative look behind

jawad@gmail.com
ali@gmail.com
jawad@hotmail.com

(?<!jawad)@.+

23.

Positive look behinde
(?<=jawad)@.+

24.

Positive look behind
box-sizing
shape-sizing
(?<=box-)sizing

25.

negative look behind
(?<!box-)sizing

26.

positive look ahead

box-sizing
box-shadow

box(?=-shadow)

27.

negative look head

box(?!-shadow)