Released Amazing Template for Phoca Cart
Learn More ...

Tips and Tricks

Category: Phoca Cart Component

Copying Attributes of Products

If one of your product includes attributes, you can copy such attributes from this product to another product(s).

Go to Administration - Components - Phoca Cart - Products. Select products to which you want to copy the attributes and click on Copy Attributes button.

Phoca Cart - Copy attributesCopy attributes

In opened window, select product from which the attributes should be copied and click on Process button.

Phoca Cart - Copy attributes to selected itemsCopy attributes to selected items

Be aware, copying of attributes can overwrite current attributes of selected products.

Setting the Required Attributes and Default Options

Sometimes it happens that the default product without attributes does not actually exist, so it is necessary to set both the attributes and their options correctly.

Example: T-Shirts. We sell t-shirts which have some size (M, L, XL) and some color (Willow, Navy, Leaf). The default basic product does not include any size and any color so in fact it does not exist. There is no t-shirt without size or color. Therefore, we must set up the product so that it is not possible to order a basic product without attributes.

First of all, we need to set right type of attribute. In our case, it is: Select, Color (Select) or Image (Select). We need to set our attribute to be required. And we need to select one option of this attribute which will be default.

Attributes - required, default optionAttributes - required, default option

Now users are not able to deselect required attributes when adding products to cart. This means that only products with selected attributes can be ordered.

Attributes - select required attributesAttributes - select required attributes

This applies to all select attributes but also to checkbox attributes. If a checkbox attribute is required, it cannot be unchecked when there is only one left.

Setting custom rules for form fields

In Phoca Cart you can create custom form fields. Such fields can be used when user enters data about himself. For example when filling in billing or delivery address in the checkout form. Form fields can include default Joomla! validate rules but it is even possible to write own rules.

Be careful, writing own validation rules should be done only by experts. If you do not have the knowledge to create validation rules, contact an expert.

Example: We need the user to fill in a text field that is a maximum of ten characters and consists only of alphanumeric characters.

There are two types of validation rules:

  • browser validation
  • server validation

Browser validation is used to prevent the user from sending an incorrectly filled out form unnecessarily. Server validation is there from a security point of view and ensures that values that do not belong to database are not stored there. Browser validation is here for user convenience, server validation protects our database. It is very important that server validation rules are complete and correct.

Browser validation rules

Browser validation rules can be set in Form fields in administration. In our example we use two options:

  • Patterns: [a-zA-Z0-9]+
  • Maxlength Attribute: 10

Form fields - browser validation rulesForm fields - browser validation rules

Such rules are set in HTML input form fields and are tested directly in browser. User is not able to enter text that is longer than 10 characters and does not consist of only alphanumeric characters.

Form fields - browser validation ruleForm fields - browser validation rule

Server validation rules

Server validation rules cannot be set so easily. Specific rules need to be written in PHP language and such file needs to be stored in following folder:

  • components/com_phocacart/models/rules/

See Alphanumeric.php file as example of server validation rule. Be aware this server validation rule file includes only validation of alphanumeric characters not the length of the string. The rule for the string length test can be found in the comment of this file. When the file is complete and ready, the name of form field rule (file name) should be set in Form fields in administration. The following option should be set:

  • Validate: Alphanumeric

Form fields - server validation ruleForm fields - server validation rule

As written earlier, server validation rule must be properly tested and should be written by experts only.

If you write your own validate rules - own files, don't forget to backup all of them.

Replace decimal comma with a point

Prices in Phoca Cart database are saved with the point (decimal point). However, in some countries a decimal comma is used instead of a decimal point. Therefore, the following parameter is to be turned on in this case:

  • Replace decimal comma with a point

In this case, if user enters a price with a decimal comma, it is automatically changed to a decimal point. This allows users not to leave their way of using keyboard.

Hide header

If you need to hide the header on Phoca Cart page, the first place to set it is the menu link to Phoca Cart.

Go to Joomla! administration - Menus - e.g. Main Menu - click on menu link to Phoca Cart - go to tab Page Display and set parameter Show Page Heading to No.

If you want to specify the header hiding for each view, this is possible using the parameter Hide Header - View in Phoca Cart options.

Hide Header parameterHide Header parameter

You can also create different combinations. For example, the Show Page Heading paramter is set to No in the menu item. Then nothing is displayed in the Categories view, but only the category name is displayed in the Category view (no menu link title). If there is no header in Categories view, you can then even insert it manually using the description.

So you can define if the header in Category view will include menu link title including category name or only a category name or nothing.


Powered by Phoca