AbleCommerce Forums
»
AbleCommerce
»
General Questions
»
9.0.4 Order.Copy() doesn't seem right to me
Rank: Advanced Member
Groups: HelpDesk, Developers Joined: 11/9/2018(UTC) Posts: 564
Thanks: 122 times Was thanked: 26 time(s) in 25 post(s)
|
When I look at the code for the .Copy() method on the Order entity, I see a few problems. No UserId assigned, no options for including shipments, items, notes etc. And the order number will immediately become a duplicate order number. is there anything better? Code:
/// <summary>
/// Create a shallow copy of this Order instance.
/// </summary>
/// <returns>A copy of this instance.</returns>
public virtual Order Copy()
{
return new Order(this.OrderNumber, this.OrderDate, this.Store, this.BillToFirstName, this.BillToLastName, this.BillToCompany, this.BillToAddress1, this.BillToAddress2, this.BillToCity, this.BillToProvince, this.BillToPostalCode, this.BillToCountryCode, this.BillToPhone, this.BillToFax, this.BillToEmail, this.OrderStatus, this.Exported, this.RemoteIP, this.Referrer, this.GoogleOrderNumber);
}
|
|
|
|
Rank: Administration
Groups: Admin, Administrators, HelpDesk, System, Authorized User, Developers, Registered Joined: 10/5/2018(UTC) Posts: 175
Thanks: 8 times Was thanked: 17 time(s) in 15 post(s)
|
This is a shallow copy method which mean that it will only copy the direct fields of the object and not the related data in associated objects. What you can do is that you can create a shallow copy and then copy the required associations before saving copied object. For order number you can set the new order number by querying the next order number.
|
|
|
|
Rank: Advanced Member
Groups: HelpDesk, Developers Joined: 11/9/2018(UTC) Posts: 564
Thanks: 122 times Was thanked: 26 time(s) in 25 post(s)
|
I can of course do all of that. But as written, that method will cause many more problems than it solves which is my point. The Copy() needs to work properly, or it should be removed.
|
|
|
|
AbleCommerce Forums
»
AbleCommerce
»
General Questions
»
9.0.4 Order.Copy() doesn't seem right to me
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.
Important Information:
The AbleCommerce Forums uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close