if ($request_type && $ppec->type) {
     $id_product = (int) Tools::getValue('id_product');
     $id_product_attribute = (int) Tools::getValue('id_p_attr');
     $product_quantity = (int) Tools::getValue('quantity');
     if ($id_product > 0 && $id_product_attribute !== false && $product_quantity > 0) {
         // Create new Cart to avoid any refresh or other bad manipulations
         $ppec->context->cart = new Cart();
         $ppec->context->cart->id_currency = (int) $ppec->context->currency->id;
         $ppec->context->cart->id_lang = (int) $ppec->context->language->id;
         $secure_key = isset($ppec->context->customer) ? $ppec->context->customer->secure_key : '';
         $ppec->context->cart->secure_key = $secure_key;
         // Customer settings
         $ppec->context->cart->id_guest = (int) $ppec->context->cookie->id_guest;
         $ppec->context->cart->id_customer = (int) $ppec->context->customer->id;
         if (!$ppec->context->cart->add()) {
             $ppec->logs[] = $ppec->l('Cannot create new cart');
             if (_PS_VERSION_ < '1.5') {
                 $display = new BWDisplay();
             } else {
                 $display = new FrontController();
             }
             $ppec->getContext()->smarty->assign(array('message' => $ppec->l('Error occurred:'), 'logs' => $ppec->logs, 'use_mobile' => $ppec->getContext()->getMobileDevice()));
             $display->setTemplate(_PS_MODULE_DIR_ . 'paypal/views/templates/front/error.tpl');
         } else {
             $ppec->context->cookie->id_cart = (int) $ppec->context->cart->id;
         }
         $ppec->context->cart->updateQty((int) $product_quantity, (int) $id_product, (int) $id_product_attribute);
         $ppec->context->cart->update();
     }
     // Set details for a payment
     $ppec->setExpressCheckout();