| ||||||||||
Shopping cart software Solutions for online shops and malls | ||||||||||
|
X-Cart Home | FAQ | Forum rules | Calendar | User manuals | Login |
Adding order meta data and displaying it places! | |||
|
|
Thread Tools | Search this Thread |
#1
|
|||||||
|
|||||||
Adding order meta data and displaying it places!
I currently have the following scenario and need some guidance.
I would like to add a piece of meta data to an order when it is created and include that data on the invoice template for the order. For argument sake let's call this data orderColor. 1) How do I create a new column to the gbxc5_orders table? (orderColor column). 2) How do I populate orderColor when the order is created? 3) How do I show the orderColor on the invoice when a admin user views the order AND when the invoice is emailed on order creation event? 4) How do I show the orderColor column on the packing slip? Any guidance would really be appreciated! Thank you. |
|||||||
#2
|
|||||||||
|
|||||||||
Re: Adding order meta data and displaying it places!
Hi Navin,
Thanks for choosing X-Cart and welcome to X-Cart forums! Quote:
The process of adding a new property to the model is described here: https://devs.x-cart.com/basics/adding_new_property_to_a_product/#decorating-model-class This example is for \XLite\Model\Product class, but you can decorate \XLite\Model\Order class all the same. Although, you will be adding orderColor property instead of myMessage. Quote:
\XLite\Model\Order class has the processSucceed() method that is run when you place an order. You should decorate it and put the code of defining processSucceed property there. Quote:
These tasks are similar to one described here: https://devs.x-cart.com/design_changes/adding_product_images_to_order_notifications.html Please, have a look at the article and you find any difficulties, please let me know. Tony
__________________
Found a bug in X-Cart? Post it to our bug tracker! Know how to make X-Cart better? Suggest an idea! |
|||||||||
#3
|
|||||||
|
|||||||
Adding a property to the model "Order"
Quote:
I have tried this, with model class Vendor/ModuleID/Model/Order.php Code:
Code:
__________________
X-cart 5.2.12, php 5.6 Ed from Grenoble, France |
|||||||
#4
|
|||||||
|
|||||||
Re: Adding order meta data and displaying it places!
By the way, the above happens with x-cart 5.4. With x-cart 5.3, I don't get the errors, but I still don't have the new properties.
__________________
X-cart 5.2.12, php 5.6 Ed from Grenoble, France |
|||||||
#5
|
|||||||
|
|||||||
Re: Adding order meta data and displaying it places!
OK, a solution was indicated in the thread https://forum.x-cart.com/showthread.php?t=76244
but adding a line Code:
__________________
X-cart 5.2.12, php 5.6 Ed from Grenoble, France |
|||||||
#6
|
|||||||||
|
|||||||||
Re: Adding order meta data and displaying it places!
You are not decorating the class?
Look at the XLite\Model\Order class annotations before the class declaration. There's probably MappedSuperclass and you need to have it in your new class as well
__________________
Steve Stoyanov CFLSystems.com Web Development |
|||||||||
#7
|
|||||||
|
|||||||
Re: Adding order meta data and displaying it places!
Well, the class annotations for \XLite\Model\Order looks like (for X cart 5.4.0.4)
Code:
By the way, the Model\Product class that I seem to be able to decorate, has annotations like Code:
Where are the differences?
__________________
X-cart 5.2.12, php 5.6 Ed from Grenoble, France |
|||||||
#8
|
|||||||||
|
|||||||||
Re: Adding order meta data and displaying it places!
Probably HasLifecycleCallbacks
But again you are not decorating the class. You are creating new class based on Model\Order so the actual Model\Order class will not have your new properties. You need define it as abstract class Order extends \XLite\Model\Order implements \XLite\Base\IDecorator in order to decorate the Model\Order class and see your new properties there
__________________
Steve Stoyanov CFLSystems.com Web Development |
|||||||||
|
#9
|
|||||||
|
|||||||
Re: Adding order meta data and displaying it places!
Quote:
Of course! How stupid was I, somehow I had deleted that part trying to debug (there were typos in other places) and didn't think about put it back again
__________________
X-cart 5.2.12, php 5.6 Ed from Grenoble, France |
|||||||
|
|||
X-Cart forums © 2001-2020
|