Developer forum

Forum » Development » RenderFrontend in ShippingProvider

RenderFrontend in ShippingProvider

Anders Ebdrup
Anders Ebdrup
Reply

Hi Dynamicweb,

 

We are working with a custom shipping provider and can see that only html can be set in the custom provider in this method

        Public Overridable Function RenderFrontend(order As Order) As String
            Return Nothing
        End Function

I really hope that maybe the template can be added to the method or we set an object that can be handled in the frontend.

 

Best regards, Anders


Replies

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

What about creating your own template parameter, render it internally and then return its output in RenderFrontend?

Imar

 
Anders Ebdrup
Anders Ebdrup
Reply

Hi Imar,

 

Yes, that is an option, but still I cannot see the use of the function just returning a string to the template. The method should at least be able to handle a template.

 

Best regards, Anders

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Why a template? In the end, all you need is HTML that gets sent to the browser. Here's an excerpt from the PostDanmark provider:

public override string RenderFrontend(Order order)
{
    if (!string.IsNullOrEmpty(ShippingProviderTemplate))
    {
        var template = new Template(ShippingProviderTemplate);
        if (string.IsNullOrEmpty(template.Html))
        {
            return string.Empty;
        }

        template.SetTag("Order.IsComplete", order.Complete);

        template.SetTag("Order.Customer.Address", order.CustomerAddress);
        template.SetTag("Order.Customer.Address2", order.CustomerAddress2);
        template.SetTag("Order.Customer.City", order.CustomerCity);
        template.SetTag("Order.Customer.Country", order.CustomerCountry);
        template.SetTag("Order.Customer.Country.Code", order.CustomerCountryCode);
        template.SetTag("Order.Customer.Region", order.CustomerRegion);
        template.SetTag("Order.Customer.Zip", order.CustomerZip);
        template.SetTag("Order.Customer.ZipCode", order.CustomerZip);

        ...
        
        RenderServicePoint(GetServicePoint(order), template, true, "ServicePoint.");

        return template.Output();
    }
    return base.RenderFrontend(order);
}

which is how I envisioned it: an interal template, that emits HTML in RenderFrontend.

Does that help?

Imar

 
Nicolai Pedersen
Reply
This post has been marked as an answer

TFS#51997, makes it possible to override Public Overridable Sub Render(template As Rendering.Template, order As Order)

Out with next Dynamicweb.Ecommerce nuget package.

Votes for this answer: 1

 

You must be logged in to post in the forum