Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Simon 81 posts 184 karma points
    Oct 20, 2016 @ 14:34
    Simon
    0

    Merchello - restrict payment gateways to products

    Hi,

    Is there any way to restrict some payment gateways to some products only? We're looking at redeveloping our existing shop and one of the products is a trial offer that is available via Direct Debit only. I can work out how to create a payment gateway to capture the additional DD information.

    However, I need to restrict the payment gateways available on this trial product to be the DD gateway only. i.e. exclude PayPal, Stripe etc.

    Any ideas on how I can go about this?

    Second questions - is there someway of exporting all order details within one of the Sales collections?

    Thanks Simon

  • Rusty Swayne 1655 posts 4993 karma points c-trib
    Oct 20, 2016 @ 15:36
    Rusty Swayne
    0

    HI Simon,

    You would need do a check in your controller. If you're using FastTrack you could create a new controller and inherit from the CheckoutPaymentMethodController and then override the method PaymentMethodForm method (from it's base)

      public class MyPaymentMethodController : CheckoutPaymentMethodController 
      {
        /// <summary>
        /// Responsible for rendering the payment method form.
        /// </summary>
        /// <param name="view">
        /// The optional view.
        /// </param>
        /// <returns>
        /// The <see cref="ActionResult"/>.
        /// </returns>
        [ChildActionOnly]
        public override ActionResult PaymentMethodForm(string view = "")
        {
            var model = CheckoutPaymentMethodModelFactory.Create();
    
             // DO YOUR CHECKS HERE AND MODIFY THE MODEL
    
            return view.IsNullOrWhiteSpace() ? PartialView(model) : PartialView(view, model);
        }
      }
    
  • Rusty Swayne 1655 posts 4993 karma points c-trib
    Oct 20, 2016 @ 15:39
    Rusty Swayne
    0

    Sorry missed the second question - there are several extension points - notifications, reporting, etc - but nothing in the core at the moment to export to a CSV or something.

    What are you looking to do?

  • Simon 81 posts 184 karma points
    Oct 27, 2016 @ 13:30
    Simon
    0

    Hi Rusty,

    Thanks for the response - sorry I was away for a few days.

    Will take a look regarding overriding the PaymentMethodForm for limiting the payment types available for different products.

    In terms of exporting, yes, I'd like to export all orders/invoices within a category to CSV file. At the moment, our fulfilment process is handled separately in a closed system (we'll develop this at some point and aim to use a notification provider to make an API call). So we need to export orders for the time being. CSV would be fine.

    I'm also going to extend Merchello's IInvoice to include an ExtendedData collection so that we can store some additional information at the invoice level. Any advice for this?

    Thanks Simon

  • Rusty Swayne 1655 posts 4993 karma points c-trib
    Oct 28, 2016 @ 15:35
    Rusty Swayne
    0

    Hey Simon,

    I think the notification provider route is going to work well.

    I've looked at adding another collection to the invoice at certain times - but always seem to come up with an easier way - I think if we added that to the core we'd wind up also needing to extend the item cache (basket, wishlist), the order and probably the shipments as well.

    What sort of information are you looking to store in the new collection?

  • Simon 81 posts 184 karma points
    Nov 02, 2016 @ 15:02
    Simon
    0

    Hi Rusty,

    Thanks for your help so far!

    How do I get hold of a custom extended product property from my overridden CheckoutPaymentMethodContoller PaymentMethodForm function? I have to check if a flag is set on one of my products before I can use a certain payment gateway.

    Re the new collection - I've decided to ditch it as I found a better way of doing it.

    Exporting orders from a Sales collection would be useful but we'd need the ability to override what was exported due to custom fields etc.

    Cheers Simon

  • Rusty Swayne 1655 posts 4993 karma points c-trib
    Nov 02, 2016 @ 16:55
    Rusty Swayne
    0

    Hi Simon,

    The Basket property is still available in CheckoutPaymentMethodController via the base class ... so you should be able to get create a MerchelloHelper and instantiate the ProductContent from items in your basket.

    Re: exporting orders - would you write up a feature request in issues.merchello.com explaining what you would like to see and how you believe it should work?

  • Simon 81 posts 184 karma points
    Nov 02, 2016 @ 17:15
    Simon
    0

    Hi Rusty

    Thanks for that - worked it out.

            var merchello = new MerchelloHelper();
            foreach(var item in Basket.Items.Where(t => t.LineItemType == Core.LineItemType.Product))
            {
                var wibble = merchello.TypedProductContent(item.ExtendedData["merchProductKey"]);
                var tony = wibble.GetProperty("brief");
            }
    

    Will add write up for the export orders function.

    Many thanks Simon

Please Sign in or register to post replies

Write your reply to:

Draft