I'm trying to override salesRule
module adding a new field customer_id
for creating rules based on an unique customer.
I've already added the new field, but now, how this module applies the rules if it matches? I'm searching aroung the module and the only thing I found is this class: SalesRule\Model\Quote\Discount
on the function collect
seems it applies discount but only for the shipping. I don't know where I have to add some code, adding this conditionality of if matches customer_id
Days ago, I made the same thing with CatalogRule
and things were a lot more intuitive, I had to made a few changes but the main goal was here:
CatalogRule\Model\ResourceModel\Rule
on this function:
public function getRulePrices(\DateTime $date, $websiteId, $customerGroupId, $productIds, $customerId = 0)
{
$connection = $this->getConnection();
$select = $connection->select()
->from($this->getTable('catalogrule_product_price'), ['product_id', 'rule_price'])
->where('rule_date = ?', $date->format('Y-m-d'))
->where('website_id = ?', $websiteId)
->where('customer_group_id = ?', $customerGroupId)
->where('product_id IN(?)', $productIds)
->where('customer_id = ? OR customer_id = 0', $customerId)
->order('sort_order', 'ASC')
->limit(1);
return $connection->fetchPairs($select);
}
As you can see, it was easy to find this query and manipulate it for achieve my objectives. But now with SalesRule
seems more complicated.
Can anyone help? I can't find documentation about this. I need to know how works all this stuff.