View Single Post
  #4  
Old 02-05-2017, 09:12 PM
 
mattstyle2 mattstyle2 is offline
 

Advanced Member
  
Join Date: Apr 2015
Posts: 54
 

Default Re: Smart Search and PHP7

I got alterdcart onepage checkout to work with php 7 and xc4.7.7

remove:
PHP Code:
// Redefine mysql_real_escape_string for PHP 7 (X-Cart 4.7.x)
if (!function_exists('mysql_real_escape_string') AND class_exists('XCDbCommon'))
{
    
// Extend X-Cart DB class to get protected $link value
    
if (!class_exists('SD_XCDbCommon'))
    {
        class 
SD_XCDbCommon extends XCDbCommon {
            public function 
getLink()
            {
                global 
$sql_obj;
                return 
$sql_obj->link;
            }
        }
    }

    
// Overwrite mysql_real_escape_string with mysqli_real_escape_string
    
function mysql_real_escape_string ($string '')
    {
        
$link = new SD_XCDbCommon();
        return 
mysqli_real_escape_string($link->getLink(), $string);
    }


from modules/cdseolinks/cdseo_config.php if you have that installed.. if not just add the code below to init.php

and move it to
/init.php after
PHP Code:
func_set_time_limit(SECONDS_PER_MIN 5); 

and add a mysql_insert_id function so it looks like this

PHP Code:
// smarty3 needs a lot of time to compile all templates_c from scratch
func_set_time_limit(SECONDS_PER_MIN 5);

// Redefine mysql_real_escape_string for PHP 7 (X-Cart 4.7.x)
if (!function_exists('mysql_real_escape_string') AND class_exists('XCDbCommon'))
{
    
// Extend X-Cart DB class to get protected $link value
    
if (!class_exists('SD_XCDbCommon'))
    {
        class 
SD_XCDbCommon extends XCDbCommon {
            public function 
getLink()
            {
                global 
$sql_obj;
                return 
$sql_obj->link;
            }
        }
    }

    
// Overwrite mysql_real_escape_string with mysqli_real_escape_string
    
function mysql_real_escape_string ($string '')
    {
        
$link = new SD_XCDbCommon();
        return 
mysqli_real_escape_string($link->getLink(), $string);
    }
    function 
mysql_insert_id ()
    {
        
$link = new SD_XCDbCommon();
        return 
mysqli_insert_id($link->getLink());
    }
    
}

/**
 * Allow displaying content in functions, registered in register_shutdown_function()
 */
$zlib_oc ini_get('zlib.output_compression'); 

This will bring back the old mysql functions


then mod /modules/Checkout_One/JSON.php (not sure this is required but I had to do it for hhvm to work).

PHP Code:
function encodeUnsafe($var)
    {
        
// see bug #16908 - regarding numeric locale printing
       // $lc = setlocale(LC_NUMERIC, 0);
       // setlocale(LC_NUMERIC, 'C');
        
$ret $this->_encode($var);
        
//setlocale(LC_NUMERIC, $lc);
        
return json_encode($var);
        
//        return $ret;
        
    

change that function to use json_encode

finally change a template file:
/skin/common_files/modules/Checkout_One/checkout_one_payment_methods.tpl
line 29:
PHP Code:
{foreach from=$payment_methods item=v}
                        <
tbody{* matt remvoe if $v.membershipids || $v.is_cod == 'Y'style="display:none;"{/if*} id="radio_trcell_{$v.paymentid}">
                            <
tr class="{cycle values='rowA,rowB'}"

just comment out the code to make things display:none.. The radio buttons for payment were not available.

seems to work.. I did a test order with a bad cc # and it declined it.. Using BSCE's authorize.net's DPM mod.. Still nned to figure out a way to subscribe mail chimp users still.. I'll update this as I work on it.

also, there's a few @mysql_query functions in the Checkout_One code you need to change to @db_query

find those..
cd modules/Checkout_One
grep -r --include="*.php" "@mysql_query"

find all instances and change to "@db_query"
there's not that many.





-Matt
__________________
4.7.7.
php7.1, AWS RDS database
memcache, reboot theme AWS EC2 load balancer, 2 c5.large instances CDSEO Shop By Filters,
AC onepage checkout and checkout tools,
altercart cash rewards, bcse DPM for paypal
Reply With Quote