how clear hikashop cart session in every 5 miunuets? when user add item in cart, if under 5 minutes , do not payment process , empty cart for user . some code of hikashop cart.php

function addToCartFromFields(&$entriesData,&$fields){
    $app = JFactory::getApplication();

    $productsToAdd = array();
    $coupons = array();
    foreach($entriesData as $entryData){
        foreach(get_object_vars($entryData) as $namekey=>$value){
            foreach($fields as $field){
                if($field->field_namekey == $namekey){
                    $ok = false;
                    if(!empty($field->field_options) && !is_array($field->field_options))
                        $field->field_options = hikashop_unserialize($field->field_options);
                        if(is_numeric($value) && is_numeric($field->field_options['product_value'])){
                            if( $value === $field->field_options['product_value'] ){
                                $ok = true;
                        }elseif(is_string($value) && !empty($field->field_options['product_value']) && is_array($field->field_options['product_value']) && in_array($value,$field->field_options['product_value'])){
                            $ok = true;
                        }elseif($value == $field->field_options['product_value']){
                            $ok = true;

                            $id = $field->field_options['product_id'];

                    if($field->field_type=='coupon' && !empty($field->coupon[$value])){
                        $coupons[] = $field->coupon[$value];

You can do it by the configuration options (version 3 of Hikashop):

Go to backend:

Hikashop -> Configuration -> Advanced -> Advanced Settings

Configure cart retaining period

  • hikashop support descript for "cart retaining period" : It's normal. The cart retaining period and frequency are done when you access the backend of the shop. The point is to clear the carts once in a while. So that you have about a few weeks or months of carts in the database and not that it grows indefinitely. Even if you set it to 5 minutes, it won't clear the carts every five minutes. Feb 1 '18 at 13:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.