proseLA / authorizenet_cim

CIM Module for authorizenet for zencart
3 stars 2 forks source link

Use zen_is_logged_in and !zen_in_guest_checkout instead of direct $_SESSION value #7

Closed lat9 closed 4 years ago

lat9 commented 4 years ago

https://github.com/proseLA/authorizenet_cim/blob/7bcf2ff0deaaedc92d081427145dd3216c0df239/includes/modules/pages/card_update/header_php.php#L6

That might get an award for the longest subject. Those functions are built into zc156 and later; don't want guest-customers to have the ability to save their credit-card information (they're guests, after all).

proseLA commented 4 years ago

ok. the card_update page is truly one of the last things on this project. i have added it here as i have already done it for my clients, but it has not gotten the cleanup that i would like. i'm trying to get everything clean like one can see here: https://github.com/proseLA/authorizenet_cim/blob/7bcf2ff0deaaedc92d081427145dd3216c0df239/includes/modules/payment/authorizenet/cim_functions.php#L3-L43

i have had to add these functions as a separate include as there was no way for one payment class to extend another...

hopefully will be ready for testing by someone other than me within a week... we will see how much headway i make...

thanks again!

proseLA commented 4 years ago

just an fyi, i was looking at this stuff, and my repo says i have not really looked at it for a couple of years. again, its far down the priority list, but i was just curious (this is the modules/pages/card_update):

Screenshot from 2020-03-31 21-38-34

proseLA commented 4 years ago

should this not be:

if (!zen_is_logged_in() and !zen_in_guest_checkout()) { // some stuff }

lat9 commented 4 years ago

Should be

if (!zen_is_logged_in() || zen_in_guest_checkout()) { // some stuff

FWIW, I try to stay away from the PHP and and or operators, using && and || instead, mostly because the subtleties of those and/or operators make my head spin (and I don't need any additional spinning).

drbyte commented 4 years ago

if (!$_SESSION['customer_id']) { if (!zen_is_logged_in() || zen_in_guest_checkout()) { // some stuff

Yes you can use those functions instead of direct checking of the session array. Which function/s to use, and whether to use ! or not all depends on your context.

I agree with using && instead of and and || instead of or wherever possible.