0

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){
    $this->resetCart(false);
    $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(!empty($field->field_options['product_id'])){
                        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;
                        }

                        if($ok){
                            $id = $field->field_options['product_id'];
                            if(empty($productsToAdd[$id])){
                                $productsToAdd[$id]=1;
                            }else{
                                $productsToAdd[$id]++;
                            }
                        }
                    }

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

1 Answer 1

0

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

Go to backend:

Hikashop -> Configuration -> Advanced -> Advanced Settings

Configure cart retaining period

1
  • 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. Commented Feb 1, 2018 at 13:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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