If this is your first visit, check our documentation. To post, register or login.
Forums / Configuring the Zen Cart Admin / Built-in Shipping and Payment Modules / /includes/modules/payment/paypal.php: What's this code supposed to do?

/includes/modules/payment/paypal.php: What's this code supposed to do?

Started by lat9 on 28 Apr 2013, 1:58 PM · Views: 2,040

Results 1 to 1 of 1
28 Apr 2013, 1:58 PM
#1
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,152
Plugin Contributions:
56

Post #1 by lat9

In v1.5.1, the instantiation function for the paypal class (in /includes/modules/payment/paypal.php) reads:

  function paypal($paypal_ipn_id = '') {
    global $order, $messageStack;
    $this->code = 'paypal';
    $this->codeVersion = '1.5.1';
    if (IS_ADMIN_FLAG === true) {
      // Payment Module title in Admin
      $this->title = STORE_COUNTRY != '223' ? MODULE_PAYMENT_PAYPAL_TEXT_ADMIN_TITLE_NONUSA : MODULE_PAYMENT_PAYPAL_TEXT_ADMIN_TITLE;
      if (IS_ADMIN_FLAG === true && defined('MODULE_PAYMENT_PAYPAL_IPN_DEBUG') && MODULE_PAYMENT_PAYPAL_IPN_DEBUG != 'Off') $this->title .= '<span class="alert"> (debug mode active)</span>';
      if (IS_ADMIN_FLAG === true && MODULE_PAYMENT_PAYPAL_TESTING == 'Test') $this->title .= '<span class="alert"> (dev/test mode active)</span>';
    } else {
      $this->title = MODULE_PAYMENT_PAYPAL_TEXT_CATALOG_TITLE; // Payment Module title in Catalog
    }
    $this->description = MODULE_PAYMENT_PAYPAL_TEXT_DESCRIPTION;
    $this->sort_order = MODULE_PAYMENT_PAYPAL_SORT_ORDER;
    $this->enabled = ((MODULE_PAYMENT_PAYPAL_STATUS == 'True') ? true : false);
    if ((int)MODULE_PAYMENT_PAYPAL_ORDER_STATUS_ID > 0) {
      $this->order_status = MODULE_PAYMENT_PAYPAL_ORDER_STATUS_ID;
    }
    if (is_object($order)) $this->update_status();
    $this->form_action_url = 'https://' . MODULE_PAYMENT_PAYPAL_HANDLER;

    if (PROJECT_VERSION_MAJOR != '1' && substr(PROJECT_VERSION_MINOR, 0, 3) != '5.0') $this->enabled = false;

    // verify table structure
    if (IS_ADMIN_FLAG === true) $this->tableCheckup();
  }

What's the purpose of the line that I've colored red? If it's meant to cause the payment module to work only on the version of Zen Cart with which it's released, it's probably a good thing that the clause is flawed because no one would ever have paypal active on v1.5.1!

If the clause ***is ***meant to limit the module's function only to a specific Zen Cart version, it should be written as

if (PROJECT_VERSION_MAJOR != '1' [B]||[/B] substr(PROJECT_VERSION_MINOR, 0, 3) != '5.0') $this->enabled = false;

Oh, and for v1.5.1 the last comparison would probably want to be changed, too.

If that's not what the clause is meant for, please fill in my blanks.

Note: Similar clauses exist in both the paypaldp and paypalwpp modules, with different minor version comparison values ...