短:我有商业产品和商业折扣,这影响了这个产品的价格。我想向商店里的用户提供这个折扣的细节。
长话短说:我使用与折扣,这是基于规则的。折扣模块用于配置产品的促销活动。有些促销(配置折扣)是有时间限制的。它们将于2015年11月11日结束。我想获得有关折扣的信息,影响产品时,显示细节。首先,我需要显示折扣结束前还有多少时间的信息。
是否有任何方法可以获得有关产品级别上的活动规则的信息?
发布于 2015-11-05 11:48:04
在行项上,有field_unit_price字段。在该字段的数据属性中,您会发现有关应用于该产品的折扣的信息:
array(1) {
["components"]=>
array(2) {
...
[1]=>
array(3) {
["name"]=>
string(22) "discount|discount_test"
["price"]=>
array(3) {
["amount"]=>
float(-240)
["currency_code"]=>
string(3) "USD"
["data"]=>
array(2) {
["discount_name"]=>
string(13) "discount_test"
["discount_component_title"]=>
string(5) "Test"
}
}
["included"]=>
bool(true)
}
}
}对组件进行迭代。如果其中一个项目有折扣,您会发现其中一个项目的名称以discount|开头。然后,您可以加载该折扣并获取有关它的更多信息:
$discount = entity_load('commerce_discount', array('discount_test'));在这里,如果添加了日期,则可以在字段commerce_discount_date上访问日期字段。
https://drupal.stackexchange.com/questions/179903
复制相似问题