November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
No, that shouldn't disappear. We are storing Project Name and retrieving that back to show on Order History Block.
OrderName = order.Properties[MetadataPlusFields.ProjectName.Name]?.ToString();
This is propery information
public static readonly MetadataPlusField ProjectName = new MetadataPlusField
{
DataType = MetaDataType.ShortString,
Description = string.Empty,
FriendlyName = "Project Name",
IsEncrypted = false,
IsMultiLanguage = false,
IsNullable = true,
IsSearchable = false,
Length = 512,
Name = "ProjectName",
Namespace = OrderContext.Current.OrderGroupMetaClass.Namespace,
};
Hi Praful :)
Thank you for your reply.
Properties on our order forms and line items are working fine. It is only on our payments that the value disappears when saving a cart as a purchaseOrder!
BR
Lasse
Can you share your code where you are setting those values on the payment?
Hej Erik :)
Here is a simplified version of the code:
public IPayment CreatePayment(ICart cart, Guid paymentMethodId, decimal amount) {
var payment = cart.CreatePayment();
PopulatePayment(payment, paymentMethodId, amount);
return payment;
}
private void PopulatePayment(IPayment payment, Guid paymentMethodId, decimal amount) {
var row = _paymentService.GetPaymentMethodRow(paymentMethodId);
payment.Amount = amount;
payment.PaymentMethodId = paymentMethodId;
payment.PaymentMethodName = row?.Name;
payment.Status = PaymentStatus.Pending.ToString();
payment.TransactionType = TransactionType.Authorization.ToString();
}
var orderForm = cart.GetFirstForm();
var voucherPayment = CreatePayment(cart, voucherPaymentMethodId, voucherAmountTobeDeducted);
voucherPayment.Properties[Metadata.Payment.VoucherCode] = response.Code;
voucherPayment.Properties[Metadata.Payment.VoucherAvailableAmount] = response.Amount;
orderForm.Payments.Add(voucherPayment);
_orderRepository.Save(cart) // IOrderRepository
And this is how I experience it when I debug:
public IPurchaseOrder PlaceOrder(ICart cart)
{
// Below is what I see when I debug (Can also be seen on the screenshots I have linked to)
var cartForm = cart.GetFirstForm(); // Debug shows: Payment in cartForm got properties
var orderReference = _orderRepository.SaveAsPurchaseOrder(cart);
var purchaseOrder = _orderRepository.Load<IPurchaseOrder>(orderReference.OrderGroupId);
var orderForm = purchaseOrder.GetFirstForm(); // Debug shows: Payment in orderForm got no properites
}
Br
Lasse
Can you try to remove the IPayment and just use GiftCardPayment directly?
public GiftCardPayment CreateVoucherPayment(ICart cart, Guid paymentMethodId, decimal amount, string voucherCode, decimal voucherAmount) {
var row = _paymentService.GetPaymentMethodRow(paymentMethodId);
var payment = new GiftCardPayment{
Amount = amount;
PaymentMethodId = paymentMethodId;
PaymentMethodName = row?.Name;
Status = PaymentStatus.Pending.ToString();
TransactionType = TransactionType.Authorization.ToString()};
payment.Properties[Metadata.Payment.VoucherCode] = voucherCode;
payment.Properties[Metadata.Payment.VoucherAvailableAmount] = voucherAmount;
return payment;
}
var voucherPayment = CreateVoucherPayment(cart, voucherPaymentMethodId, voucherAmountTobeDeducted, response.Code, response.Amount);
(Disclaimer: free hand code so might not even be formatted correctly)
Hi Quan,
Dooh :/
It helped adding a equivalent metafield to payment?
Thanks a lot to all of you for spending time looking into my issue. It is much appreciated.
Thanks! :)
Hi Forum,
I have a question about "IExtendedProperties". After saving a cart as a purchaseOrder, the values added to "IExtendedProperties" on payments disappear.
Is it a bug or intended behavior. Do I misunderstand something? :)
Screenshot cart order form
https://screenpresso.com/=j1wlf
Screenshot purchaseOrder order form
https://screenpresso.com/=DZgdc
Code
EpiServer.Business.Commerce
12.17.2.3575
BR
Lasse