Author Archives: samir

Xform field validation using regular expression

xform regular expression for validation

Title Expression Example
US phone validation      /^\(?(\d{3})\)?[-\. ]?(\d{3})[-\. ]?(\d{4})$/ 555-555-1212, (555)-555-1212), 555 555 1212, 555.555.1212, (555).555.1212
UK Phone Validation  /^(\+44\s?7\d{3}|\(?\d{5}\)?)\s?\d{3}\s?\d{3}$/ 07222 555555, (07222) 555555, +44 7222 555 555
ZIP code validation    /^[0-9]{10}$/
UK postal validation    /[A-Z]{1,2}[0-9][0-9A-Z]?\s?[0-9][A-Z]{2}/i
Image Validation   /image\/jpeg|image\/png|image\/gif|image\/jpg/  jpg, png and gif
PDF file validation  /application\/pdf|application\/x-pdf/
Alphabet String Length   /^[a-zA-Z]{3,7}$/   Min length 3 and max length is 7
Any String Length   /^.{5,20}$/   Min length 5 and max length is 20

How to remove twig cache in OC 3.x

There is a tiny developer menu in opencart 3.x that can be overlooked easily but it is very essential for every developer or store owner. All we know that since OC 3.x, it uses twig as template engine and we often need to remove twig cache. We can remove twig cache by removing files in storage/cache directory using ftp. Interesting that it is possible to remove template cache from developer menu that can be found admin dashboard easily. Here are the steps:

  1. First check you have enough permission to modify developer menu by editing User group.

2. Developer menu can be found in admin dashboard

3. It will open a popup whenever you click on developer menu. Now you can refresh/remove twig cache by clicking on Refresh icon. Also it is possible to remove SASS cache from that popup.

Video tutorials on Xshippingpro

I don’t know Lee Ashby personally but I would like to give a big thanks for making few wonderful videos on X-shippingpro in his youtube channel. Lee Ashby, I owe you a cup of coffee! Thank you buddy!

Here are the video links:

X-shipping Pro Opencart Shipping Tutorial – Basic Flat Rate

X-shipping Pro Opencart Shipping Tutorial – Free Shipping

X-shipping Pro Opencart Shipping Tutorial – Groups & Geo Location

X-Shipping Pro Opencart Shipping Tutorial – Heavy Item Surcharge

 

 

 

 

First level grouping vs Second level grouping in xshippingpro

In xshippingpro, there are two levels of grouping:

  1. Group of methods – First level grouping is based on Group Field  and
  2. Group of groups – second level grouping is based on Sort Order field.

Xshippingpro first calculate grouping based on Group field and finally it calculate grouping again based on Sort Order Fields.

Second level grouping need very seldom. Most of the cases, first/top level grouping is enough to achieve the scenario. However, it might be needed second level grouping in few cases.
Why do you need groupping basically? Sometimes we come up in a situation when we have to take decision what to do in a special case. For example, You want to charge shipping cost $5 if any item is chosen from category A and shipping cost $10 when any item is chosen from Category B. But what will happen when someone want to purchase from both category A and B? Well, you may want sum the shipping cost up Or want to proceed with highest Shipping cost.

You can then let xshippingpro know your decision through groupping mode. For doing so, you will have to navigiate to group mode option, then Choose Group1 is Sum or whatever you want. Now, You will have to assign this group to each of the applicable shipping method in the General tab. Under general tab of the method, you will find an option “Group”. This is field where you need to be assigned it. If you don’t need any group, you can just keep it as “None”.

This way, you can make up to 10 groupings amonst your shipping methods. One method can belong to only one group at a time.

Now let discuss Group of groups or second level grouping. For example, you have 5 top level groups like I discussed above. Now you have come up in a situation where you may need to sum up the cost of  the groups. This is very rare case but it may be needed. Thats why Group of Group is only one. To make grouping within groups, you first choose Group mode i.e either it is sum or highest etc.

Then you will have to choose shipping methods for this group. Unfortunately, there is no selection field for this kind of grouping like first level grouping. Xshippingpro consider value of the Sort Order field that is located under general tab to find out or calculate such grouping. Method having same Sort order value will be considered as a group. For example,  if you have chosen “Group of groups” is Sum. Now method-A and method-B has sort order value is 1. Now xshippignpro, will consider these two method as a group. So whenever both methods shall become activate simultaneously, xshippignpro will show one method instead of both depending on Group mode (sum, average etc).

Group of groups will even work if you don’t have first/Top level grouping. If you choose any Group mode of “Group of groups“, the it will be activate regardless of first level groups. It will just check methods which have same sort order values and will turn these into a group.

Shipping Cost per 100gm with additional $10

how to set following situation?

initial charge(Rate per parcel) $10
Plus rate per 100g or part thereof $1

So if customer buy an item of 300g
Total charge is $13 (1 x $10 + 3 x $1)

Thanks for your query. Please do following:

1. Under Price setting tab, Select Rate type is Weight.

I am assuming that your default weight unit is gram. If it is KG, then you will have to enter it accordingly. For example, 100 will be replaced with 0.1

Now enter following Unit Ranges:

Start . —- End . —- Cost —- per unit block —- Allow partial 
0 —- 999999 — 1 —– 100 – – — – – NO

Explanation:
——-
a. First define a big ranges 0 – 999999 so that it covers all weight
b. Per unit block ensure that it will charge $1 per 100 gram
c. Allow partial ensure that it will not charge partial block. SO it will charge $3 for 250 grams instead of $2.5

2. Under Price adjustment section, enter +10 into the field “Modifier” [+10 means it will add $10 with final cost]

Using of AND group mode in xfeepro

I do not know how to configure it.
What I need is below:
If shopping cart include any product in category A, a discount is based on percentage of  all  Category A products.
For example:
Category A include Product I of $10, product II of $5.
Category B include product III of $30
If shopping cart include
2 Product I (category A):   2*10
1 Product III (category B): 1*30
Then discount= percentage of 2*10
Could you explain to me how to setup this rule?
Thanks for contacting and using xfeepro.
Configuring conditional logic is bit complex. But this can be achieved by Group mode option. Group mode option can be found under general setting tab. Fee having same Sort order  value will consider as a group. Sort order field can be found under general tab of each method.
For conditional mode, you will have to choose Group mode is AND. Now if you create two methods and assign same sort order value, those two methods will act as a group and one method won’t be appeared unless other method become valid. Noted that in group mode AND, price will be calculated from first fee, remain fees will be used just for other condition validation.
Lets start configuration:
First, under General Setting tab, Select Group mode is AND
Since you need to calculate cost based on category A, so we will create that fee first and then will create the other fee that will be just used for validating category condition.
First fee for category A
———–
1. Create a new fee and enter a name
2.  Under General tab, enter sort order value is 1  [Or whatever but need to be entered same value into the the fee so grouping can work]
3. Under Product/Category Tab, select Category Rule is “Any of the selected categories with other”. Then choose your applicable categories for which you want to offer discount. In your case these are Category A
4. Under Price setting tab, Select Rate type is Flat and enter your discount percentile into fee cost. For example: 5%
5. Now in the same tab, Select “Percentage related to” is “Sub-total Fee specific” .   [Sub-total Fee specific ensure that xfeepro would consider the products of chosen categories only]
First fee for category B
———–
1. Create a new fee and enter a name
2.  Under General tab, enter sort order value is 1  [This must be same as previous one]
3. Under Product/Category Tab, select Category Rule is “Any of the selected categories with other”. Then choose your conditional categories In your case these are Category B
Keep other setting as their default. Since this will be used just for category conditioning thing.

how to overwrite default contact page by xform’s form?

You will have to follow following steps if you want to overwrite default contact form by form created by xform.

  1. Enable layout module option in Xform -> Integration.
  2.  Add following css rule Xform -> Other Tab into Custom CSS section. This is needed to hide default contact form.

3. Now navigate to Design -> Layout , Now edit Contact Layout. Finally add your form at Content bottom position.

That’s all.

 

How to use Integrate third party payment gatway using xpayment?

Scenario -1

You have a payment gateway, that needs to send some datas (like total amount, API key etc) to their server and payment gateway will do all necessary things on their server and return back to your store once processing is done with payment data.

How to implement?

  1. Since it needs to redirect to payment gateway with some datas. So first select Integration type is “Redirect/Forward to Payment URL”
  2. Now enter the payment gateway URL where it need to be redirected/forwarded.
  3. Now you will have to enter all data as JSON format into Data(s) section. You can use few placeholders like {orderTotal}, {currency} etc that xpayment will handle accordingly. Xpayment also has a special placeholder {returnURL} that basically a special URL so that you can return to store from payment gateway. Most of the payment gateway, it need to supply return URL into data section OR it can be set on payment gateway control panel. Return URL denotes basically http://YOUR_DOMAIN/index.php?route=extension/payment/xpayment/confirm
  4. Now select return method type that means how your payment gateway will reply back to store. It could be GET or POST or JOSN. Normally it can be found in payment gateway manual.
  5. Finally, you will have to enter a payment successful condition. That means after returning back from Payment gateway to your store, it can be successful or failure transaction. Normally, it can be found in payment gateway manual. Most of the cases, they send some data like success==true or something like that where success is variable name that will available in their response.
  6. Now xpayment will do remaining things what to do. Either it will reject or accept depending on the data.

Scenario -2

You have a payment gateway, that needs to call their provided API URL/endpoint from your store without leaving your store. it may need to provide some data while calling that API URL.

How to implement?

1. Since it needs to call API with some datas. So first select Integration type is “API Call”
2. Now enter the payment gateway API URL that need to be called.
3. Now you will have to enter all data as JSON format into Data(s) section.
4. Now select API response type. It could be GET or POST or JOSN.
5. Finally, you will have to enter a payment successful condition.

Actually it needs some developing knowledge to integrate payment gateway.

Postal Rules in xshippingpro

Xshippingpro support following postal rules.
Rule 1:  Numeric Postal Range

Range should be defined by single hyphen (-). For example, 100-200 denotes postal codes 100 to 200. If you need multiple ranges, just separated these by comma(,). For example, 100-200,300-400.

Rule 2:  Prefix-Range  (Prefix hyphen range)

Prefix can be anything. Range should be like Rule 1 that means numeric postal range. Example: KW-10-15 denotes KW10,  KW11, KW12, KW13, KW14 and KW15

 Rule 3:  Prefix-Range-Suffix  (Prefix hyphen Range hyphen suffix)

Prefix and suffix can be anything. Range should be like Rule 1 that means numeric postal range. Example: KW-10-15-EE denotes KW10EE,  KW11EE, KW12EE, KW13EE, KW14EE and KW15EE

Rule 4: Postal codes separated by comma(,).  For example, 1000, AE1111 etc.

Finally, you can use wild cards in the prefix, suffix and single postal codes.

For example, PA2* denotes any postal code starting by PA2.

Again, KW-1-5-* denotes KW1XX, KW2XX, KW5XX and so on. Here XX means anything due to *

Several rules can be mixed together separated by comma. For example: 1200, AE-1-5-*,PA2*

Grouping in x-shipping Pro

In Xshippingpro, you can divide all shipping methods up to ten group. Why do you need grouping?  It can be used following cases:

  1. You can hide/filter out unwanted shipping method at certain scenario. For example, You have two shipping methods a. Free Shipping when order total is greater than $100 and b. Flat Shipping $20. So whenever a customer purchase products worth more than $100, it will show two shipping methods during checkout which are Free Shipping and Flat Shipping. Since it is bit awkward having free shipping and flat shipping at a same time. So you can hide Flat shipping whenever Free shipping activates. we can hide it using group feature.
  2. Merge or combine shipping cost of several shipping methods into one. For example, You want to charge $5 per product for category A and $7 per product for category B. So you have created two shipping methods. One for category A and another for Category B. Whenever customer purchase products from category A and Category B together, you want to sum up the cost. Group option can do that.
  3. Enrichment of rules –  You can link several methods into one. xshippingpro will check every rules of all the linked methods before showing it in the site. If any rules failed any of the linked methods, it will be not be appeared. For example, sometime you may want to charge shipping cost based on order total and Quantity. But xshippingpro does not support two rate type at the same method. So you can create two different methods, one method for order total and another method for quantity, then link these two methods into one using grouping option so that it validates both order total and quantity rules.

It support following group type or mode:

  1. Lowest   –  It will show the method which have lowest cost among the group methods
  2. Highest  –   It will show the method which have highest cost among the group methods
  3. Average –   It will average the cost of the group methods.
  4. Sum –   It will sum up the cost of the group methods.
  5. AND –  Special type. It has been used for rule enrichment that described in item 3 above.

For defining several method as a group, first you will have to navigate in Xshippingpro -> Global setting -> Group Option

Now select Group type from available ten groups.  You can also enter a group name. This group name will be appeared instead of Method name if group become activate during checkout. This group name can be combined with original method name and its price as well. For placing first method name, you will have to put #1, for the second method name #2 and so on. Also possible to put price like name by placing @1, @2 and so on.

Now you will have to assign your group number to the methods that you need to be linked together under general setting of each method.

Group creation is done!

Finally, it is also possible to make group from the Groups! This is called Group of groups. This group will determine based on Sort Order value defined on general tab of the each method. Shipping method having same sort order value will be placed into same group. Group of groups also can be Lowest, Highest, Average and Sum.

 

To know more details about top level grouping (Group of methods) and Second level grouping (Group of Groups), please check this