Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
rule_free_shipping_by_product_weight.php
Go to the documentation of this file.
1 <?php
7 require 'cart_rule_free_shipping.php';
8 $row =
9  [
10  'name' => 'Free shipping if item weight <= 1',
11  'conditions' => [
12  1 =>
13  [
14  'type' => \Magento\SalesRule\Model\Rule\Condition\Combine::class,
15  'attribute' => null,
16  'operator' => null,
17  'value' => '1',
18  'is_value_processed' => null,
19  'aggregator' => 'all',
20  'conditions' => [
21  [
22  'type' => Magento\SalesRule\Model\Rule\Condition\Address::class,
23  'attribute' => 'weight',
24  'operator' => '<=',
25  'value' => '1',
26  'is_value_processed' => false,
27  ]
28  ]
29  ]
30 
31  ],
32  'actions' => [],
33  ];
34 $salesRule->loadPost($row);
35 $salesRule->save();