X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Third Party Add-Ons for X-Cart 4 (https://forum.x-cart.com/forumdisplay.php?f=45)
-   -   altered carts OnSale mod for php 7+ (https://forum.x-cart.com/showthread.php?t=76935)

keystone 04-25-2019 10:27 AM

altered carts OnSale mod for php 7+
 
I bought the unencrypted files from AlteredCart for the OnSale mod when Bill was closing up shop, did anyone else do that so they could update the files for php7+? I don't have enough coding knowledge to know what I'm doing and was looking to see if anyone has it working already.
Thanks.

elmirage001 04-25-2019 12:18 PM

Re: altered carts OnSale mod for php 7+
 
I use AC's Cash Rewards and had an issue with PHP 7.x because AC Cash Rewards uses mysql_real_escape_string() which is not supported in PHP 7.x.

Check your log files to see if you have a PHP error for mysql_real_escape_string()

If yes maybe the following will help.

Steve pointed me to X-Cart's func_addslashes($html_escape) so I added the following to func.core.php

After:
Code:

function func_get_internal_banners($type)
{
    global $sql_tbl;

    if (empty($type)) {
        return;
  }

    $return = func_query("SELECT * FROM $sql_tbl[internal_banners] WHERE type='$type'");
    return $return;
}


Add:
Code:

function mysql_real_escape_string($html_escape)
{
  return func_addslashes($html_escape);
}


keystone 04-25-2019 12:50 PM

Re: altered carts OnSale mod for php 7+
 
thanks for the reply elmirage but i didn't even get that far yet, I was just wondering if anyone one had done it successfully yet.

Thomasb134 04-25-2019 08:26 PM

Re: altered carts OnSale mod for php 7+
 
I can't offer any direct advice with porting the AC OnSale module. But I know what you are up against. I'm nearly done with doing that to Bill's Checkout One (one page checkout) module. It's been a horrible experience but I think I've finally beaten it.

You can get a feel for some issues by testing the module's php files using these online PH7 compatibility tools:
https://phpcodechecker.com/
https://www.piliapp.com/php-syntax-check/


As mentioned in the previous post, you'll need to recreate the missing mysql_real_escape_string() function. And I suspect there will be some instances of the deleted mysql_query() function (removed in PHP7). It can be replaced with db_query().

Be sure to work from a development store because it may take awhile to sort through all the problems that come up.

No doubt there will be more to it than these things. But if you post about the issues that pop up then maybe the community can walk you through it.

BTW, I'm using XC's Onsale Module (X-HotProducts) and it is working in my 4.4.5 store with PH7, no patches.

elmirage001 04-25-2019 09:34 PM

Re: altered carts OnSale mod for php 7+
 
I second Thomas's recommendation of X-Cart's Onsale module. I've been using it for a few years now. Our sales change a lot so I'm putting things on sale and taking others off sale all the time. I got tired of the labor intensive process very quickly so I came up with the following.

Final version is the last post.

https://forum.x-cart.com/showthread.php?t=75341

Paul

keystone 05-24-2019 01:33 PM

Re: altered carts OnSale mod for php 7+
 
The problems I have with x-carts Onsale module are that you can't do nearly the types of sales such as buy 2 get one free, spend x get x discount on the order, etc. I guess it works ok if you just want to do straight discounts on individual products but AC onsale mod spoiled me I think.

Thomas, thanks for the links to the tools, I'll give them a shot. I added the code to the func.core.php file as a start so I'll see how it goes.

elmirage001 05-24-2019 02:06 PM

Re: altered carts OnSale mod for php 7+
 
jQuery was updated in 4.7.11 and I had to update a section of Bill's code in his Cash Rewards. You may need to check his code for any thing deprecated.

For example Bill used .live but it is now deprecated and I had to change as shown below.
From:
Code:

// Cash Rewards :: www.alteredcart.com //
$('.unsetCashRewards').live('click', this._unsetRewards);
$('.applyRewardButton').live('click', this._applyRewards);
// Cash Rewards :: www.alteredcart.com //

To:
Code:

// Cash Rewards :: www.alteredcart.com //
$(document).on('click','.unsetCashRewards',this._unsetRewards);
$(document).on('click','.applyRewardButton',this._applyRewards);
// Cash Rewards :: www.alteredcart.com //


I didn't know initially that .live was the issue. I found by a process of elimination (the long and painful method) :-)

This page showed me how to fix the issue. http://api.jquery.com/live/

Hopefully you won't have any jQuery issues to worry about. Good luck!

Paul

keystone 06-03-2019 11:07 AM

Re: altered carts OnSale mod for php 7+
 
Using the recommended PHP Code Checker I have this issue...

session_register is depreciated

I have this code
Code:

// Page Control //
x_session_register('page_control');

if (!$page_control && empty($change)){
        $page_control = 'overview';
}

if (!empty($change)){
        $page_control = $change;
}


I see that the recommended fix is
Two things that came to my mind:

Quote:

Using global variables is not good anyway, find a way to avoid them.
You can still set variables with $_SESSION['var'] = "value".

Can someone show me how to fix this one? I'm not sure how, once I see and example I should be able to fix the rest of the instances on my own (hopefully)
Thanks.

cflsystems 06-03-2019 11:46 AM

Re: altered carts OnSale mod for php 7+
 
x_session_register is XC function not PHP function. It is declared in include/sessions.php I believe. There is nothing to fix.

keystone 06-03-2019 12:35 PM

Re: altered carts OnSale mod for php 7+
 
ah, ok. Thanks.


All times are GMT -8. The time now is 06:24 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.