Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

altered carts OnSale mod for php 7+
 
Reply
   X-Cart forums > X-Cart 4 > Third Party Add-Ons for X-Cart 4
 
Thread Tools
  #11  
Old 06-06-2019, 01:23 PM
 
keystone keystone is offline
 

X-Adept
  
Join Date: Jul 2006
Location: USA
Posts: 720
 

Default Re: altered carts OnSale mod for php 7+

I did get this error with the php code checker...

Quote:
Warning: There is 1 array declaration that contains a single equal sign '=' instead of '=>':

Code:
array(func_query_first_cell("SELECT categoryid FROM $sql_tbl[products_categories] WHERE productid='".$product['productid']."' AND main='Y'"))

It that really an error or is the code ok?
__________________
www.uscandleco.com - Version 4.6.6
mods:
Reboot template
cdseo pro
AC-one page checkout
running on UNIX

www.keystonecandle.com -Version 4.6.0
mods:
cdseo pro
AC-onsale
running on UNIX
Reply With Quote
  #12  
Old 06-07-2019, 10:33 AM
 
keystone keystone is offline
 

X-Adept
  
Join Date: Jul 2006
Location: USA
Posts: 720
 

Default Re: altered carts OnSale mod for php 7+

So i've made a few changes to the OnSale mod to try and get it in line with php7.2 and here one I'm stuck on... I currently have
Code:
if (db_query("UPDATE xcart_onsale SET begin='$begin', end='$end', saletype='$saletype', criteria='".addslashes(serialize($product_criteria))."', coupon_code='$coupon_code', uses='$times_to_use', home_display='$home_display', onsale_product_display='$onsale_product_display', onsale_display='$onsale_display', per_customer='$per_customer', productids='$productids', catids='$catids', provider='$login', status='".mysqli_real_escape_string($sale_status)."' WHERE onsaleid='$edit_update'")){
and get the error
Quote:
Warning: mysqli_real_escape_string() expects exactly 2 parameters, 1 given in /home/keyston1/public_html.dev/admin/onsale.php on line 677

Apparently I need to add the connection to the db in the mysqli function part
Code:
.mysqli_real_escape_string($my_connection,$sale_status)
I'm not sure what $my_connection should actually say...?
and am I headed in the right direction?
Thanks.
__________________
www.uscandleco.com - Version 4.6.6
mods:
Reboot template
cdseo pro
AC-one page checkout
running on UNIX

www.keystonecandle.com -Version 4.6.0
mods:
cdseo pro
AC-onsale
running on UNIX
Reply With Quote
  #13  
Old 06-07-2019, 10:56 AM
 
Thomasb134 Thomasb134 is online now
 

X-Adept
  
Join Date: Apr 2007
Location: USA
Posts: 756
 

Default Re: altered carts OnSale mod for php 7+

Don't update the original code to use mysqli_real_escape_string(). Instead, leave the old code as-is and recreate the missing mysql_real_escape_string() function that was removed in PHP7.

The details on how to do it are explained here:
https://forum.x-cart.com/showpost.php?p=410661&postcount=10
.
__________________
Thomas / USA
XCart V4.4.5 Gold
XCart Mobile V1.4.12
XCart X-PDF
XCart X-HotProducts
AlteredCart Checkout One (One Page Checkout)
BCSE Back In Stock
CFL Holiday Message
CFL System Message
Smack Digital (WebsiteCM) Remember Anon Carts
xcartmods Testimonials
Unix, PHP 7.0 (patched 5.4). Currently patching PHP 7.1
MySQL 5.6
Reply With Quote

The following user thanks Thomasb134 for this useful post:
elmirage001 (06-08-2019)
  #14  
Old 06-07-2019, 11:57 AM
 
keystone keystone is offline
 

X-Adept
  
Join Date: Jul 2006
Location: USA
Posts: 720
 

Default Re: altered carts OnSale mod for php 7+

I notice that post says if it is the ionCube version than that fix won't help. The instructions in the Bills unencrypted source code says that
Quote:
The licensing for the module uses ionCube
does that mean I can't use the fix?
__________________
www.uscandleco.com - Version 4.6.6
mods:
Reboot template
cdseo pro
AC-one page checkout
running on UNIX

www.keystonecandle.com -Version 4.6.0
mods:
cdseo pro
AC-onsale
running on UNIX
Reply With Quote
  #15  
Old 06-07-2019, 12:12 PM
 
Thomasb134 Thomasb134 is online now
 

X-Adept
  
Join Date: Apr 2007
Location: USA
Posts: 756
 

Default Re: altered carts OnSale mod for php 7+

In the Final weeks of Bill closing down his business he provided unencrypted source code (ioncube removed) to existing customers for a small fee. It was a limited time offer.

If that is what you have then you can ignore the ioncube license comment in his instructions since it does not apply.
__________________
Thomas / USA
XCart V4.4.5 Gold
XCart Mobile V1.4.12
XCart X-PDF
XCart X-HotProducts
AlteredCart Checkout One (One Page Checkout)
BCSE Back In Stock
CFL Holiday Message
CFL System Message
Smack Digital (WebsiteCM) Remember Anon Carts
xcartmods Testimonials
Unix, PHP 7.0 (patched 5.4). Currently patching PHP 7.1
MySQL 5.6
Reply With Quote
  #16  
Old 06-07-2019, 12:13 PM
 
keystone keystone is offline
 

X-Adept
  
Join Date: Jul 2006
Location: USA
Posts: 720
 

Default Re: altered carts OnSale mod for php 7+

Looks like it may have worked, stand by.
__________________
www.uscandleco.com - Version 4.6.6
mods:
Reboot template
cdseo pro
AC-one page checkout
running on UNIX

www.keystonecandle.com -Version 4.6.0
mods:
cdseo pro
AC-onsale
running on UNIX
Reply With Quote

The following user thanks keystone for this useful post:
elmirage001 (06-08-2019)
  #17  
Old 07-05-2019, 09:47 AM
 
keystone keystone is offline
 

X-Adept
  
Join Date: Jul 2006
Location: USA
Posts: 720
 

Default Re: altered carts OnSale mod for php 7+

I'm still working through this and am getting this Warning...

count(): Parameter must be an array or an object that implements Countable

here are the 2 lines of code it referring to...

Code:
$smarty->assign('pidCount'count(): Parameter must be an array or an object that implements Countable, count(isset($sale['criteria']['purchase_products']) ? $sale['criteria']['purchase_products'] : 0)+count(isset($sale['criteria']['received_products']) ? $sale['criteria']['received_products'] : 0)+1); $smarty->assign('wPidCount', count(isset($sale['criteria']['wholesale']) ? $sale['criteria']['wholesale'] : 0)+1);

Should this be different for php7?
__________________
www.uscandleco.com - Version 4.6.6
mods:
Reboot template
cdseo pro
AC-one page checkout
running on UNIX

www.keystonecandle.com -Version 4.6.0
mods:
cdseo pro
AC-onsale
running on UNIX
Reply With Quote
  #18  
Old 07-05-2019, 10:46 AM
 
Thomasb134 Thomasb134 is online now
 

X-Adept
  
Join Date: Apr 2007
Location: USA
Posts: 756
 

Default Re: altered carts OnSale mod for php 7+

That warning was suppressed in earlier PHP versions. But now PHP7.2+ has elevated the warning to encourage better coding practices.

The solution is to test the variable to confirm it is countable BEFORE counting it. It would be something like this:
Code:
$smarty->assign('wPidCount', (($sale['criteria']['wholesale'] instanceof Countable) && count(isset($sale['criteria']['wholesale'])) ? $sale['criteria']['wholesale'] : 0)+1);

This is just a coding example and may not work as-is. My example is just to give you a fundamental idea on how to fix it.

BTW, PHP7.3 introduced the is_countable() function as alternate way to do the "instanceof Countable" var test. Details here:
https://www.php.net/manual/en/function.is-countable.php

.
__________________
Thomas / USA
XCart V4.4.5 Gold
XCart Mobile V1.4.12
XCart X-PDF
XCart X-HotProducts
AlteredCart Checkout One (One Page Checkout)
BCSE Back In Stock
CFL Holiday Message
CFL System Message
Smack Digital (WebsiteCM) Remember Anon Carts
xcartmods Testimonials
Unix, PHP 7.0 (patched 5.4). Currently patching PHP 7.1
MySQL 5.6
Reply With Quote

The following user thanks Thomasb134 for this useful post:
elmirage001 (07-07-2019)
Reply
   X-Cart forums > X-Cart 4 > Third Party Add-Ons for X-Cart 4


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 03:21 AM.

   

 
X-Cart forums © 2001-2018