Quote:
Originally Posted by cflsystems
It is not only the order items table, discounts/surcharges are also registered in the order surcharges table.
|
It is precisely this kind of details that makes me finding a "shortcut" to "XC way". So,
basically I would need, besides the usual classes (Viewer, Controller, whatever is needed
to get forms), a Model class to decorate /Model/Order/Surchare.php, and a class extending Logic/Order/Modifier/Discount.php, or am I still missing something?
Quote:
I'd suggest you follow the XC way of working with discounts/surcharges instead of direct changes to number sin database as this may just not always work properly
|
OK, so let's forget about the netPrice column, although I wonder why it is there if it is the result of calculation. At least for one of the modules I am writing, I don't mind changing the values of "price" column in OrderItem table, which is actually done in XC's stock class. As far as I understand, there is the class /View/ItemsList/Model/OrderItem.php, which starts with
Code:
namespace XLite\View\ItemsList\Model;
/**
* OrderItem items list
*/
class OrderItem extends \XLite\View\ItemsList\Model\Table
{
use \XLite\View\Base\ViewListsFallbackTrait;
/**
* Widget param names
*/
const PARAM_ORDER = 'order';
This widget is called from the twig file xcart/skins/admin/order/page/parts/items/items.twig as
Code:
{{ widget('\\XLite\\View\\ItemsList\\Model\\OrderItem', order=this.order) }}
So the twig files call the widget with 'order' as parameter. However, I can't figure out from which view class the twig gets the value of this.order. So I can't figure out how to pass this parameter to the twig.
For example, if I try to feed the "value" of "order" by doing something like
/View/Page/Admin/Demo.php
Code:
protected function getDefaultTemplate()
{
return 'modules/order/page/parts/items/items.twig';
}
protected function getOrder()
{
$id=1;
$order = \XLite\Core\Database::getRepo('XLite\Model\Order')->find($id);
return $order;
}
it leads to an internal error, instead of showing a widget to edit the order with
order_id=1. Any idea on what I am doing wrong here?