neilzb wrote:Hi,
I have Paypal Express on my site, but ow do I add it to the 'topcart'?
Thanks
Neil
Do you want it in flout cart? if yes
Create a partial view in Shared folder with following code and then call it
@using Nop.Core
@using Nop.Core.Domain.Orders
@using Nop.Core.Infrastructure
@using Nop.Services.Orders
@using Nop.Services.Payments
@{
#region Button payment methods
var currentCustomer = EngineContext.Current.Resolve<IWorkContext>().CurrentCustomer;
var _storeContext = EngineContext.Current.Resolve<IStoreContext>();
var _paymentService = EngineContext.Current.Resolve<IPaymentService>();
var cart = currentCustomer.ShoppingCartItems
.Where(sci => sci.ShoppingCartType == ShoppingCartType.ShoppingCart)
.LimitPerStore(_storeContext.CurrentStore.Id)
.ToList(); ;
var paymentMethods = _paymentService
.LoadActivePaymentMethods(currentCustomer.Id, _storeContext.CurrentStore.Id)
.Where(pm => pm.PaymentMethodType == PaymentMethodType.Button)
.Where(pm => !pm.HidePaymentMethod(cart))
.ToList();
foreach (var pm in paymentMethods)
{
if (cart.IsRecurring() && pm.RecurringPaymentType == RecurringPaymentType.NotSupported)
{
continue;
}
string actionName;
string controllerName;
RouteValueDictionary routeValues;
pm.GetPaymentInfoRoute(out actionName, out controllerName, out routeValues);
@Html.Action(actionName, controllerName, routeValues)
}
#endregion
}
let's say file name _PaypalExpressCheckoutButton.cshtml in path: ~\Views\Shared\_PaypalExpressCheckoutButton.cshtml
Call it like bellow from the file ~\Views\ShoppingCart\FlyoutShoppingCart.cshtml
@Html.Partial("_PaypalExpressCheckoutButton")
Note: It will load all Button type payment mentods