I would normally use the TB Stripe module but I need a subscription function for the magazines we sell. I have a Stripe module that enables that but since switching to PHP 7.3, I get the following error in my php error log:
count(): Parameter must be an array or an object that implements Countable in /home/zbookstore/public_html/modules/stripepro/stripepro.php on line 410
Here is the code on and around line 410, where line 410 is in red:
/**
* [hookHeader => change add to cart button with subscribe button on home page as well as on product page]
* @param [type] $params [array containing information of the product]
* @return [type] [description]
*/
public function hookHeader($params)
{
if (Tools::getValue('controller') == 'product')
{
$product_id = Tools::getValue('id_product');
if(!empty($product_id))
{
$sub = Db::getInstance()->getValue('select `id_subscription_product` from `'._DB_PREFIX_.'stripepro_products` where `active` = 1 && `id_product_attribute`=0 && `id_product`= '.$product_id);
if($sub != '')
{
$this->context->smarty->assign('controller','product');
return $this->display(__FILE__, 'subscribe.tpl');
}
}
}
else
{
/* Continue only if we are in the checkout process */
if (Tools::getValue('controller') != 'order-opc' && (!($_SERVER['PHP_SELF'] == __PS_BASE_URI__.'order.php' || $_SERVER['PHP_SELF'] == __PS_BASE_URI__.'order-opc.php' || Tools::getValue('controller') == 'order' || Tools::getValue('controller') == 'orderopc' || Tools::getValue('step') == 3 || Tools::getValue('controller') == 'supercheckout' || Tools::getValue('pm') == 'stripepro'))){
$subscribe_products = Db::getInstance()->executeS('select * from `'._DB_PREFIX_.'stripepro_products` where `active`= 1 && `id_product_attribute`=0 '); if (count($subscribe_products > 0))
{
$this->context->smarty->assign('subscriptions',$subscribe_products);
return $this->display(__FILE__, 'subscribe.tpl');
}
} else {
$nbProducts = $this->context->cart->nbProducts();
if ($nbProducts<=0)
return;
public function checkCurrency($cart)
{
$currency_order = new Currency($cart->id_currency);
$currencies_module = $this->getCurrency($cart->id_currency);
if (is_array($currencies_module)) {
foreach ($currencies_module as $currency_module) {
if ($currency_order->id == $currency_module['id_currency']) {
return true;
}
}
}
return false;
}
Any insights on how to fix this would be very appreciated. Thanks!
Question
movieseals
I would normally use the TB Stripe module but I need a subscription function for the magazines we sell. I have a Stripe module that enables that but since switching to PHP 7.3, I get the following error in my php error log:
Here is the code on and around line 410, where line 410 is in red:
/**
* [hookHeader => change add to cart button with subscribe button on home page as well as on product page]
* @param [type] $params [array containing information of the product]
* @return [type] [description]
*/
public function hookHeader($params)
{
if (Tools::getValue('controller') == 'product')
{
$product_id = Tools::getValue('id_product');
if(!empty($product_id))
{
$sub = Db::getInstance()->getValue('select `id_subscription_product` from `'._DB_PREFIX_.'stripepro_products` where `active` = 1 && `id_product_attribute`=0 && `id_product`= '.$product_id);
if($sub != '')
{
$this->context->smarty->assign('controller','product');
return $this->display(__FILE__, 'subscribe.tpl');
}
}
}
else
{
/* Continue only if we are in the checkout process */
if (Tools::getValue('controller') != 'order-opc' && (!($_SERVER['PHP_SELF'] == __PS_BASE_URI__.'order.php' || $_SERVER['PHP_SELF'] == __PS_BASE_URI__.'order-opc.php' || Tools::getValue('controller') == 'order' || Tools::getValue('controller') == 'orderopc' || Tools::getValue('step') == 3 || Tools::getValue('controller') == 'supercheckout' || Tools::getValue('pm') == 'stripepro'))){
$subscribe_products = Db::getInstance()->executeS('select * from `'._DB_PREFIX_.'stripepro_products` where `active`= 1 && `id_product_attribute`=0 ');
if (count($subscribe_products > 0))
{
$this->context->smarty->assign('subscriptions',$subscribe_products);
return $this->display(__FILE__, 'subscribe.tpl');
}
} else {
$nbProducts = $this->context->cart->nbProducts();
if ($nbProducts<=0)
return;
$this->smarty->assign($this->getPaymentVars());
$this->context->controller->addCSS($this->_path.'views/css/stripe-prestashop.css');
$this->context->controller->addJS("https://js.stripe.com/v2/");
$this->context->controller->addJS("https://js.stripe.com/v3/");
if(Configuration::get('STRIPE_CHKOUT_POPUP') || Configuration::get('STRIPE_ALLOW_BTC'))
$this->context->controller->addJS("https://checkout.stripe.com/checkout.js");
return $this->display(__FILE__, './views/templates/front/vars_payment.tpl');
}
}
}
public function checkCurrency($cart)
{
$currency_order = new Currency($cart->id_currency);
$currencies_module = $this->getCurrency($cart->id_currency);
if (is_array($currencies_module)) {
foreach ($currencies_module as $currency_module) {
if ($currency_order->id == $currency_module['id_currency']) {
return true;
}
}
}
return false;
}
Any insights on how to fix this would be very appreciated. Thanks!
3 answers to this question
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now