Make PayPal option invisible for prohibited items

For general questions and discussions specific to the AbleCommerce GOLD ASP.Net shopping cart software.
Post Reply
jill224
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 23
Joined: Sat Aug 22, 2009 3:19 pm
Location: Northaeast Pennsylvania

Make PayPal option invisible for prohibited items

Post by jill224 » Thu Sep 18, 2014 3:40 pm

Hi all,

We have recently run into an issue with PayPal restrictions on certain items we sell so we are in the process of prohibiting several specific items from being used in PayPal transactions. I have used the "prohibit item from PayPal/Google checkout" option in the advanced settings for the specified products, however I see that the PayPal option is still showing (on Checkout/Payment.aspx) when you try to checkout with any of these items in your basket. We need to make sure that "PayPal" is not displaying at all as an option if customers try to buy any of these items.

viewtopic.php?f=42&t=14977#p64238

I did see this old post which seems to be covering the same problem but it is reference to an old version of AC and the code is now different. I am currently using Gold R6 and was hoping someone might be able to offer a suggestion of what can be done to make PayPal option invisible if customer has any prohibited item in their basket. Any help is very much appreciated.

Thank you!

User avatar
Katie
AbleCommerce Admin
AbleCommerce Admin
Posts: 2651
Joined: Tue Dec 02, 2003 1:54 am
Contact:

Re: Make PayPal option invisible for prohibited items

Post by Katie » Fri Sep 19, 2014 6:38 am

Currently, there isn't a feature that prohibits the item from PayPal. That feature was added a long time ago and was specific to Google Checkout. As of last spring, Google dropped their payment system. So, I will put in a request to have the "Prohibited" option work with PayPal instead, because that would be better than removing it all together.
Thank you for choosing AbleCommerce!

http://help.ablecommerce.com - product support
http://wiki.ablecommerce.com - developer support

jill224
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 23
Joined: Sat Aug 22, 2009 3:19 pm
Location: Northaeast Pennsylvania

Re: Make PayPal option invisible for prohibited items

Post by jill224 » Mon Sep 22, 2014 7:10 am

That is unfortunately misleading as the option on the Edit Product page reads "Item is prohibited by Google or Paypal checkout." We had always been under the impression that we were able to prohibit items from PayPal if necessary. I had assumed that the option would prohibit them from both Google and Paypal Checkout. We had never actually used Google Checkout and only recently started using PayPal so had not had an opportunity to test it out until this recent issue arose. It would definitely be a great option to have and would help us out tremendously. Do you think this will be something they will include in future versions, or is there any way possible to do a patch where the option can be switched to refer to PayPal in past versions?

Would anyone be aware of any other options in the meantime to prohibit only select items from being allowed to checkout using PayPal?

Thanks again.

nadeem
Captain (CAPT)
Captain (CAPT)
Posts: 258
Joined: Tue Jul 31, 2012 7:23 pm

Re: Make PayPal option invisible for prohibited items

Post by nadeem » Tue Sep 23, 2014 3:43 am

To make the PayPal option invisible for prohibited items, you need to do the following updates:

Open Website/Conlib/PayPalExpressCheckoutButton.ascx.cs, locate the following line of code:

Code: Select all

// FIND THE PAYPAL GATEWAY
PayPalProvider provider = AbleCommerce.Code.StoreDataHelper.GetPayPalProvider();
and replace with:

Code: Select all

Basket basket = AbleContext.Current.User.Basket;
foreach (BasketItem item in basket.Items)
{
    if (item.OrderItemType == OrderItemType.Product)
    {
        if (item.Product.IsProhibited)
        {
             this.Visible = false;
             return;
        }
    }
}

// FIND THE PAYPAL GATEWAY
PayPalProvider provider = AbleCommerce.Code.StoreDataHelper.GetPayPalProvider();
This will hide the express checkout button from basket pages.

If you want to hide the standard paypal option from payment page, Open Website/ConLib/Checkout/PaymentWidget.ascx.cs and add the following code:

Code: Select all

protected void Page_PreRender(object sender, EventArgs e)
{
    if (this.Basket != null)
    {
        foreach (BasketItem item in this.Basket.Items)
        {
           if (item.OrderItemType == OrderItemType.Product)
           {
              if (item.Product.IsProhibited)
              {
                 foreach (ListItem li in PaymentMethodList.Items)
                 {
                     if (li.Text == "PayPal")
                         li.Attributes.CssStyle.Add("visibility", "hidden");
                }
             }
           }
        }
}

jill224
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 23
Joined: Sat Aug 22, 2009 3:19 pm
Location: Northaeast Pennsylvania

Re: Make PayPal option invisible for prohibited items

Post by jill224 » Tue Sep 23, 2014 4:04 pm

Hi Nadeem,

I just tested this out and it did exactly what I needed.

Thank you so much for taking time out to post this. It has really helped us out and I truly do appreciate it!

Post Reply