Page 1 of 5 123 ... LastLast
Results 1 to 10 of 47
  1. #1
    Join Date
    Jan 2009
    Posts
    2,123
    Plugin Contributions
    0

    Default Enable PayPal but Only when Product ID 1234 is in cart?

    We don't use PayPal generally. However, we would like PayPal to be an option when customers have a specific product ID in their cart. Is there a way to customise the code for this?

    Maybe a tweak I could make to \includes\modules\payment\paypalwpp.php ?

  2. #2
    Join Date
    Jan 2007
    Location
    Australia
    Posts
    6,167
    Plugin Contributions
    7

    Default Re: Enable PayPal but Only when Product ID 1234 is in cart?

    Quote Originally Posted by limelites View Post
    We don't use PayPal generally. However, we would like PayPal to be an option when customers have a specific product ID in their cart. Is there a way to customise the code for this?
    There's always a way to customise code :)


    Quote Originally Posted by limelites View Post
    Maybe a tweak I could make to \includes\modules\payment\paypalwpp.php ?
    I can't see why that wouldn't work.

    Do a search for threads discussing how to enable/disable specific shipping methods based on particular products. (There are serveral of them).

    The same principles would apply for the payment methods... Essentially it involves just setting the "$this->enabled" to be true or false on demand.

    Cheers
    Rod

  3. #3
    Join Date
    Jan 2009
    Posts
    2,123
    Plugin Contributions
    0

    Default Re: Enable PayPal but Only when Product ID 1234 is in cart?

    Quote Originally Posted by RodG View Post
    There's always a way to customise code :)




    I can't see why that wouldn't work.

    Do a search for threads discussing how to enable/disable specific shipping methods based on particular products. (There are serveral of them).

    The same principles would apply for the payment methods... Essentially it involves just setting the "$this->enabled" to be true or false on demand.

    Cheers
    Rod
    Hi Rod,

    I've searched prior to posting and there's one thread in particular that's useful but it's a closed thread so I can't post a reply there and it's sort of doing the opposite of what I need:

    http://www.zen-cart.com/showthread.p...rtain-products

    In the thread above, they're de-activating PayPal on certain products. My problem is that as soon as I activate the PayPal module, it will be active for all 1100 products on the site. I want to activate the PayPal module but immediately have it disabled for all products, unless the product ID is 1234.

    So I'm struggling to find a way. Any help would be greatly appreciated.

  4. #4
    Join Date
    Jan 2007
    Location
    Australia
    Posts
    6,167
    Plugin Contributions
    7

    Default Re: Enable PayPal but Only when Product ID 1234 is in cart?

    Quote Originally Posted by limelites View Post
    it's sort of doing the opposite of what I need:
    they're de-activating PayPal on certain products.

    My problem is that as soon as I activate the PayPal module, it will be active for all 1100 products on the site. I want to activate the PayPal module but immediately have it disabled for all products, unless the product ID is 1234.

    So I'm struggling to find a way. Any help would be greatly appreciated.
    It is *exactly* the same principle, but the logic needs to be reversed.

    Near the start of the code wil lbe something like
    $this->enabled = ((MODULE_PAYMENT_PAYPAL_STATUS == 'True') ? true : false);

    What this is doing is reading the admin configuration setting for the module to set the 'default'. IOW, if MODULE_PAYMENT_PAYPAL_STATUS == 'True' then $this->enabled will be set to 'true'. Otherwise it will be set to false.

    Changing $this->enabled at some point *after* the code above will act as an over-ride for this setting. So, a single line like

    $this->enabled = false ;

    Will have the same effect as if you had disabled the module from your admin settings.

    Now all you need to as add your product check, and if found, set $this->enabled = true ;


    Something like:

    // enable if products_id 1234 is in the cart
    if ($_SESSION['cart']->in_cart_check('products_id','1234') > 0) { $this->enabled = true;}

    Cheers
    Rod

  5. #5
    Join Date
    Jan 2009
    Posts
    2,123
    Plugin Contributions
    0

    Default Re: Enable PayPal but Only when Product ID 1234 is in cart?

    Hi Rod,

    I don't have time to try this at the moment as we're just about to leave for the weekend but thank you for the very clear and concise tutorial with a breakdown of the logic and syntax required. You've been really helpful. Thank you!

  6. #6
    Join Date
    Jan 2009
    Posts
    2,123
    Plugin Contributions
    0

    Default Re: Enable PayPal but Only when Product ID 1234 is in cart?

    Update.... Ten minute delay so I gave it a whil but it doesn't seem to work. I enabled PayPal Express in admin, then edited /includes/modules/payment/paypalwpp.php with this:

    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.3.8a';
    $this->enableDirectPayment = (MODULE_PAYMENT_PAYPALWPP_DIRECT_ENABLED == 'True');
    $this->enabled = (MODULE_PAYMENT_PAYPALWPP_STATUS == 'True');
    // disable, (even when admin has it switched on):
    $this->enabled = false;
    // enable if products_id XXXX is in the cart:
    if ($_SESSION['cart']->in_cart_check('products_id','1395') > 0) { $this->enabled = true;}


    It doesn't seem to do anything, PayPal express is enabled no matte what's in the cart. I think something's missing or not quite right.

  7. #7
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Enable PayPal but Only when Product ID 1234 is in cart?

    Try changing the code for line:
    Code:
    // disable, (even when admin has it switched on):
        $this->enabled = false;
    if ($_SESSION['cart']->in_cart_check('products_id','1395') > 0) { $this->enabled = true;}
    to read:
    Code:
    if (!IS_ADMIN_FLAG) {
      // disable, (even when admin has it switched on):
      $this->enabled = false;
      if ($_SESSION['cart']->in_cart_check('products_id','1395') > 0) { 
        $this->enabled = true;
      }
    }
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  8. #8
    Join Date
    Jan 2007
    Location
    Australia
    Posts
    6,167
    Plugin Contributions
    7

    Default Re: Enable PayPal but Only when Product ID 1234 is in cart?

    Quote Originally Posted by limelites View Post
    Update.... Ten minute delay so I gave it a whil but it doesn't seem to work..
    Please follow any and all suggestions provided by Ajeh


    The info I gave was 'off the top of my head' with a couple of 'crude' cut and pastes to demonstrate what would be required.

    Ajeh on the other hand is the real expert in this type of modification and her advice and suggestions usually produce something fully functional :)

    I bow to her expertise every time, without question :)

    Cheers
    Rod

    ps. Thanks for stepping in Ajeh.

  9. #9
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Enable PayPal but Only when Product ID 1234 is in cart?

    Always easy to clean up other's code ... especially when pretty close ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  10. #10
    Join Date
    Jan 2009
    Posts
    2,123
    Plugin Contributions
    0

    Default Re: Enable PayPal but Only when Product ID 1234 is in cart?

    I've tried and it doesn't work. PayPal option comes up regfardless of the product ID. Here's the link of code:

    PHP 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.3.8a';
        
    $this->enableDirectPayment = (MODULE_PAYMENT_PAYPALWPP_DIRECT_ENABLED == 'True');
        
    $this->enabled = (MODULE_PAYMENT_PAYPALWPP_STATUS == 'True');
        
    // disable, even when admin has it switched on:
    if (!IS_ADMIN_FLAG) {
      
    // disable, (even when admin has it switched on):
      
    $this->enabled false;
      global 
    $cart;
      if (
    $_SESSION['cart']->in_cart_check('products_id','1395') > 0) { 
        
    $this->enabled true;
      }

    Maybe I'm editing the wrong file?

 

 
Page 1 of 5 123 ... LastLast

Similar Threads

  1. disable flat rate shipping for paypal only (but enable for googlecheckout)
    By btman in forum Built-in Shipping and Payment Modules
    Replies: 6
    Last Post: 14 Jul 2009, 05:51 AM
  2. When I enable Featured products, only one product is displayed.
    By creativearc in forum Templates, Stylesheets, Page Layout
    Replies: 4
    Last Post: 6 May 2008, 01:30 AM
  3. Product info shifts left when mouse over nav buttons, but only in IE !
    By bigbadbob in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 1 Mar 2008, 08:32 AM
  4. Show quantity in cart only when the product is already in shopping cart
    By e81ny in forum Templates, Stylesheets, Page Layout
    Replies: 15
    Last Post: 8 Sep 2007, 03:34 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