Modifying the admin interface

Gabor Ferencz asked on June 1, 2015 12:40

Hello,

I have a scenario, where we have an ecommerce website built using the MVC approach. This website uses discounts, and with the introduction of the new discount types, they want to leverage these. We had to write the code to apply discounts to the basket ourselves with the MVC model, so I'm not investigating how to apply the Buy X get Y discount.

We have also customized the product variant section of the system - it's all coming from a third party system, so variants are created like:

Product Name: My Product 1
Variant Name: 15 Pipettes

Product Name: My Product 2
Variant Name: 15 Pipettes

This is fine in the MVC front-end, because that's how the product is displayed, but when I go into the Buy X get Y admin interface, the product simply displays as:

  • 15 Pipettes
  • 15 Pipettes
  • 3 Capsules
  • 3 Capsules
  • 3 Capsules
  • 1 Tablet
  • etc...

So my question is where can I modify the buy X get Y admin interface, so that selecting a product in the BUY and GET sections displays the full name of the product?

Additionally, is the shopping cart clever enough to know if I set up a buy x get y discount, to then automatically apply this (assuming no coupon is required?)

I hope I'm being clear with the question... Thanks in advance!

Recent Answers


Brenden Kehren answered on June 1, 2015 13:32

Create your own custom module. There you can create your own webparts and/or templates and display them in the UI.

Yes, if you place the buy X get Y web part on the shopping cart page it's smart enough, if you don't, I don't believe it is.

0 votesVote for this answer Mark as a Correct answer

Gabor Ferencz answered on June 2, 2015 10:54 (last edited on June 2, 2015 10:54)

Thanks Brenden, I hope you don't mind me asking a couple of further questions?

I have established that the shopping cart IS clever enough to apply discounts automatically, so if you have a Buy X Get Y discount without a coupon in place, it will apply automatically.

Additionally, you can get these discounts back from the cart using:

ShoppingCart.OrderRelatedDiscountSummaryItems

So that's great! However, I cannot see a Buy X Get Y web part anywhere? Also, when creating a custom module, I'd really just like to have the current BUY X Get Y interface but just customizing what comes back in the product selector. I got as far as getting to: Modules > E-commerce > User Interface > New Buy X Get Y discount > Design > but then from here, where do I create the new custom module?

Thanks again for your help!

0 votesVote for this answer Mark as a Correct answer

Josef Dvorak answered on June 2, 2015 21:25

Hello Gabor,

The name displayed is determined by macro. So the easiest solution to write a simple Custom Macro Method, to which you will pass the SKUID and SKUParentSKUID, and which will return a string composed of the SKUNames of the Parent and Variant. You will then enter this macro to:

Development -> Modules -> E-commerce -> Classes -> Multibuy discount -> Alternative forms -> GeneralBuyOneGetOne -> BuyProductSet -> Advanced -> Display name format

0 votesVote for this answer Mark as a Correct answer

Gabor Ferencz answered on June 3, 2015 13:40

Thank you Josef,

This seems like exactly what I was looking for.

I have made some headway on this, but I'm really struggling on passing the SKU ID through to the macro. Hereis my macro code:

[assembly: RegisterExtension(typeof(SKUVariantMacros), typeof(SystemNamespace))]
public class SKUVariantMacros : MacroMethodContainer
{

    [MacroMethod(typeof(string), "Gets the fully qualified name of the variant", 1)]
    [MacroMethodParam(0, "param1", typeof(int), "The ID of the variant SKU")]
    public static object GetSkuParentVariantName(EvaluationContext context, params object[] parameters)
    {
        var skuID = ValidationHelper.GetInteger(parameters[0], 0);
        var variant = VariantHelper.GetVariantById(skuID);
        if (variant == null)
        {
            var skuInfo = SkuHelper.GetSKUById(skuID);
            if (skuInfo != null) return skuInfo.SKUName;
            else return "";
        }
        return variant.ProductName + " - " + variant.VariantName;
    }
}

And then this is how I'm calling it:

{%GetSkuParentVariantName(SKUID)%}

I have opened the extended field editor using the little arrow next to: Display name format, as without this, it wasn't working. I was getting a db error.

Can you tell me what I'm doing wrong?

Regards, Gabor

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.