Results 1 to 10 of 10
  1. #1
    Join Date
    Jun 2016
    Posts
    20
    Plugin Contributions
    0

    Default Paypal Express Minimum amount [HELP]

    Dear all,

    I had spent tremendous amount of time searching for similar threads, found it but new problem arised. Would appreciate if someone could help me understand.

    I inserted an if else condition to paypal express module to prevent palpal option from appearing less than 20 amount. It worked well until the final stage. After clicking confirm order, it wont connect to paypal page (the circle paypal loading page) and show the page isnt working.

    Below is my code if someone could help. Additions are bolded in the middle of the text wall.

    Code:
    function paypalwpp() {
        include_once(zen_get_file_directory(DIR_FS_CATALOG . DIR_WS_LANGUAGES . $_SESSION['language'] . '/modules/payment/', 'paypalwpp.php', 'false'));
        global $order;
        $this->code = 'paypalwpp';
        $this->codeTitle = MODULE_PAYMENT_PAYPALWPP_TEXT_ADMIN_TITLE_EC;
        $this->codeVersion = '1.5.1';
        $this->enableDirectPayment = FALSE;
        $this->enabled = (MODULE_PAYMENT_PAYPALWPP_STATUS == 'True');
        
      if ($order->info['subtotal'] < 20.00){$this->enabled=false;}
        else {$this->enabled=true;}
        
        // Set the title & description text based on the mode we're in ... EC vs US/UK vs admin
        if (IS_ADMIN_FLAG === true) {
          $this->description = sprintf(MODULE_PAYMENT_PAYPALWPP_TEXT_ADMIN_DESCRIPTION, ' (rev' . $this->codeVersion . ')');
          switch (MODULE_PAYMENT_PAYPALWPP_MODULE_MODE) {
            case ('PayPal'):
              $this->title = MODULE_PAYMENT_PAYPALWPP_TEXT_ADMIN_TITLE_EC;
            break;
            case ('Payflow-UK'):
              $this->title = MODULE_PAYMENT_PAYPALWPP_TEXT_ADMIN_TITLE_PRO20;
            break;
            case ('Payflow-US'):
              if (defined('MODULE_PAYMENT_PAYPALWPP_PAYFLOW_EC') && MODULE_PAYMENT_PAYPALWPP_PAYFLOW_EC == 'Yes') {
                $this->title = MODULE_PAYMENT_PAYPALWPP_TEXT_ADMIN_TITLE_PF_EC;
              } else {
                $this->title = MODULE_PAYMENT_PAYPALWPP_TEXT_ADMIN_TITLE_PF_GATEWAY;
              }
            break;
            default:
              $this->title = MODULE_PAYMENT_PAYPALWPP_TEXT_ADMIN_TITLE_EC;
          }

  2. #2
    Join Date
    Jul 2012
    Posts
    16,028
    Plugin Contributions
    17

    Default Re: Paypal Express Minimum amount [HELP]

    Two things.
    1) the code snippet above will enable the plugin even if it was turned off on the admin because of the else statement that sets enabled to true if the price is at or above 20.00.
    2) at the point of completing the order, the subtotal array value doesn't exist anymore because the $order->info is generated from other values which can be used to determine the subtotal, but the subtotal is not used.

    Two solutions to the second "problem" come to mind.
    1) the "easiest" is to check if the subtotal key exists, if it doesn't then carry on with whatever enabled status was previously set. If it does exist, then compare to your chosen price.
    2) if the subtotal doesn't exist, then determine it from say taking the total (which does exist) and subtracting the shipping_cost or the shipping_cost and tax depending on whether DISPLAY_PRICE_WITH_TAX is true or not respectfully.

    The function to check for existence of a key in an array would be like:
    Code:
    array_key_exists('subtotal', $orders->info)
    and returns true if it does
    Also understand that in a series of and statements: if (true && false && generates_an_error) that php stops processing the logic as soon as any value is false. So it doesn't matter in some regards how incorrect later tests are if an earlier test proved to be false.

    As to the else part? I would leave it off so that previous control logic still applied.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  3. #3
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    10,630
    Plugin Contributions
    78

    Default Re: Paypal Express Minimum amount [HELP]

    No need to be carving up core-files; I'm closing down for the day, but I'll post a teeny file update that will do the trick.

  4. #4
    Join Date
    Jun 2016
    Posts
    20
    Plugin Contributions
    0

    Default Re: Paypal Express Minimum amount [HELP]

    Quote Originally Posted by mc12345678 View Post
    Two things.
    1) the code snippet above will enable the plugin even if it was turned off on the admin because of the else statement that sets enabled to true if the price is at or above 20.00.
    2) at the point of completing the order, the subtotal array value doesn't exist anymore because the $order->info is generated from other values which can be used to determine the subtotal, but the subtotal is not used.

    Two solutions to the second "problem" come to mind.
    1) the "easiest" is to check if the subtotal key exists, if it doesn't then carry on with whatever enabled status was previously set. If it does exist, then compare to your chosen price.
    2) if the subtotal doesn't exist, then determine it from say taking the total (which does exist) and subtracting the shipping_cost or the shipping_cost and tax depending on whether DISPLAY_PRICE_WITH_TAX is true or not respectfully.

    The function to check for existence of a key in an array would be like:
    Code:
    array_key_exists('subtotal', $orders->info)
    and returns true if it does
    Also understand that in a series of and statements: if (true && false && generates_an_error) that php stops processing the logic as soon as any value is false. So it doesn't matter in some regards how incorrect later tests are if an earlier test proved to be false.

    As to the else part? I would leave it off so that previous control logic still applied.
    Thank you all for your input, i am grateful for the effort.

    I tried changing the subtotal to total - shipping cost, as coded below

    Code:
     if (($order->info['total']-=$order->info['shipping_cost']) < 20.00){$this->enabled=false;}
        else {$this->enabled=true;}
    It worked just like subtotal but still could not get past the final stage connect to paypal. Did i overlooked something? Thank you!

  5. #5
    Join Date
    Jun 2016
    Posts
    20
    Plugin Contributions
    0

    Default Re: Paypal Express Minimum amount [HELP]

    Bump!~ Anyone enlighten me please! Thank you!

  6. #6
    Join Date
    Jul 2012
    Posts
    16,028
    Plugin Contributions
    17

    Default Re: Paypal Express Minimum amount [HELP]

    Quote Originally Posted by thymine View Post
    Thank you all for your input, i am grateful for the effort.

    I tried changing the subtotal to total - shipping cost, as coded below

    Code:
     if (($order->info['total']-=$order->info['shipping_cost']) < 20.00){$this->enabled=false;}
        else {$this->enabled=true;}
    It worked just like subtotal but still could not get past the final stage connect to paypal. Did i overlooked something? Thank you!
    I was kind of waiting for lat9's input before continuing down the path of modifying the core file.
    Also, personally the bump of this thread made it easier to which to return, but in the forum that is typically not an acceptable practice. Those offering assistance do so when they are able or willing.

    That said I will say this, the code provided above does a modification to the total and a comparison, so it too could be a cause to the issue. Are you getting any error logs when it gets to that last screen?

    My untested suggestion for the code if going to modify the PayPal module is the following:
    Code:
    $min_pp_enabled = 20.00;
     if (array_key_exists('subtotal', $order->info)) {
        if($order->info['subtotal'] < $min_pp_enabled) {
          $this->enabled=false;
        }
     } elseif (DISPLAY_PRICE_WITH_TAX == 'true') {
       if(($order->info['total'] - $order->info['shipping_cost']) < $min_pp_enabled) {
         $this->enabled=false;
        }
     } else {
      if(($order->info['total'] - $order->info['shipping_cost'] - $order->info['tax']) < $min_pp_enabled) {
        $this->enabled=false;
      }
     }
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  7. #7
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    10,630
    Plugin Contributions
    78

    Default Re: Paypal Express Minimum amount [HELP]

    As promised, just place this content into the file: /includes/modules/pages/checkout_payment/header_php_no_ppwpp_gt_20.php:
    Code:
    <?php
    // -----
    // Created by lat9; Copyright (C) 2016 Vinos de Frutas Tropicales
    //
    // If the order's subtotal is greater than 20 and the PayPal Express Checkout is enabled, disable it!
    //
    if ($order->info['subtotal'] > 20 && is_object ($paypalwpp)) {
        $paypalwpp->enabled = false;
    }
    Like I'd indicated before, no core file overwrites!

  8. #8
    Join Date
    Jun 2016
    Posts
    20
    Plugin Contributions
    0

    Default Re: Paypal Express Minimum amount [HELP]

    Quote Originally Posted by lat9 View Post
    As promised, just place this content into the file: /includes/modules/pages/checkout_payment/header_php_no_ppwpp_gt_20.php:
    Code:
    <?php
    // -----
    // Created by lat9; Copyright (C) 2016 Vinos de Frutas Tropicales
    //
    // If the order's subtotal is greater than 20 and the PayPal Express Checkout is enabled, disable it!
    //
    if ($order->info['subtotal'] > 20 && is_object ($paypalwpp)) {
        $paypalwpp->enabled = false;
    }
    Like I'd indicated before, no core file overwrites!
    Thank you very much for your coding, just to clarify,
    1. header_php_no_ppwpp_gt_20.php, do you mean header.php? I do not find a header_php_no_ppwpp_gt_20 folder there.
    2. Do i just put it on the first line? Sorry for the newbie question, i should be ashamed

    Thank you!

  9. #9
    Join Date
    Jul 2012
    Posts
    16,028
    Plugin Contributions
    17

    Default Re: Paypal Express Minimum amount [HELP]

    Quote Originally Posted by thymine View Post
    Thank you very much for your coding, just to clarify,
    1. header_php_no_ppwpp_gt_20.php, do you mean header.php? I do not find a header_php_no_ppwpp_gt_20 folder there.
    2. Do i just put it on the first line? Sorry for the newbie question, i should be ashamed

    Thank you!
    A new file named as provided is what is recommended. Everything after header_php could be whatever desired, but something recognizable has been suggested. :)
    So the file would have the name provided and the contents of what was pasted. Be sure not to have any spaces, blank lines etc before the first <?php.

    Also, you may want to change the comparison logic as what has been provided is to deactivate PayPal instead of allow it to be active when greater than 20.00. Would then also change the portion of the filename from _gt_ to _lt_
    Last edited by mc12345678; 4 Jun 2016 at 04:24 PM.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  10. #10
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    10,630
    Plugin Contributions
    78

    Default Re: Paypal Express Minimum amount [HELP]

    Thanks for the catch, mc12345678, that's what I get putting that up pre-coffee.

    @thymine, if you take the code below and create the new file /includes/modules/pages/checkout_payment/header_php_no_ppwpp_lt_20.php, you'll be good-to-go. As mc1-8 indicated, the portion of the filename that I've highlighted can be anything you want, but it must start with header_php_.
    Code:
    <?php
    // -----
    // Created by lat9; Copyright (C) 2016 Vinos de Frutas Tropicales
    //
    // If the order's subtotal is greater than 20 and the PayPal Express Checkout is enabled, disable it!
    //
    if ($order->info['subtotal'] < 20 && is_object ($paypalwpp)) {
        $paypalwpp->enabled = false;
    }

 

 

Similar Threads

  1. minimum amount
    By broeder in forum Built-in Shipping and Payment Modules
    Replies: 58
    Last Post: 27 Jan 2013, 06:33 PM
  2. Paypal Express Checkout vs. minimum order module
    By miffy22 in forum PayPal Express Checkout support
    Replies: 1
    Last Post: 19 Sep 2011, 11:46 PM
  3. urgent! total amount transfer to Paypal Express does not include coupon discount
    By weber in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 17
    Last Post: 26 Sep 2009, 06:45 AM
  4. Paypal Express Checkout not showing the amount or the items??
    By mthem2003 in forum PayPal Express Checkout support
    Replies: 2
    Last Post: 23 Feb 2008, 06:50 PM
  5. PayPal site doesn't show the order and the amount with express checkout
    By koolos.com in forum PayPal Express Checkout support
    Replies: 3
    Last Post: 7 Jan 2008, 04:09 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR