Developer forum

Forum » Ecommerce - Standard features » Shorten productname for Afterpay

Shorten productname for Afterpay

Martijn Bokhove
Reply

Hi

We have a customer who uses Afterpay as one of the paymentmethods with Ogone as provider.
It works great, the only problem is that Afterpay has a conflict with productnames above 40 characters.

I have tried to shorten the productname in the cart with the Cart Notificationsubscriber, but it seems it's to ignore my shortened name.

This is what I've tried:

For Each ol As Orders.OrderLine In curOrder.OrderLines
  If ol.ProductName.Length > 39 Then
      Dim shortName As String = Left(ol.ProductName, 36) & "..."
      ol.ProductName = shortName
      ol.Save()
  End If
Next
curOrder.OrderLines.Save(curOrder.ID)
curOrder.Save()
Dynamicweb.eCommerce.Frontend.Cart.CartCatch.SaveCart()

Is there another way to shorten the name?

Gr
Martijn

 


Replies

 
Nicolai Høeg Pedersen
Reply

Hi Martijn

If the orderline has an instance of a product (orderline.product), the name of the product is what is returned from ProductName property.

So try setting the Orderline.Product.Name to the shortened string ALSO and do not save the product, but only the orderline.

It is a bug - the productname should always come from the orderline productname property.

 

The property code for understanding:

Public Property ProductName() As String
            Get
                If Not IsNothing(_Product) AndAlso Not String.IsNullOrEmpty(_Product.Name) Then
                    Return _Product.Name
                Else
                    Return _ProductName
                End If
            End Get
            Set(ByVal Value As String)
                _ProductName = Value
            End Set
        End Property
 
Martijn Bokhove
Reply

Hi Nicolai

Thanks for your reply.

It works with saving the productname also, unfortunately not for long.
We don't save the product, but still it's being replaced every step in the cart with the full productname.

Because we cannot invoke all the steps in the cart, it uses the full name for payment and mail.

Is there another way to get the name shortened?

Gr
Martijn

 
Nicolai Høeg Pedersen
Reply
This post has been marked as an answer

Hi Martijn

You can try with the OrderIsPassedToCheckoutHandler notification which is broadcastet just before sending the cart to the checkouthandler, hence the Ogone.

http://developer.dynamicweb-cms.com/api8/#Dynamicweb~Dynamicweb.Notifications.eCommerce+Cart~OrderIsPassedToCheckoutHandler.html

A more extensive way would be creating a new custom field on the product catalog "Full product name" and let that be the product name that is used in product lists and details, and use the normal product field for the shorten version.

Or you can get the code for the Ogone checkouthandler and modify it...

Nicolai

Votes for this answer: 1
 
Martijn Bokhove
Reply

Hi Nicolai

Just run some tests with the OrderIsPassedToCheckoutHandler and that's exactly what's desired.
The name is only shortened for Afterpay, in all the other screens and e-mail the long productname is visible.

Thanks!

Gr
Martijn

 

You must be logged in to post in the forum