Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
cart_rule_free_shipping_by_cart.php
Go to the documentation of this file.
1 <?php
7 require 'cart_rule_free_shipping.php';
8 
9 $row =
10  [
11  'name' => 'Free shipping for cart if item price >10',
12  'is_active' => 1,
15  'conditions' => [
16  1 =>
17  [
18  'type' => \Magento\SalesRule\Model\Rule\Condition\Combine::class,
19  'attribute' => null,
20  'operator' => null,
21  'value' => '1',
22  'is_value_processed' => null,
23  'aggregator' => 'all',
24  ]
25 
26  ],
27  'actions' => [
28  1 => [
29  'type' => Magento\SalesRule\Model\Rule\Condition\Product\Combine::class,
30  'attribute' => null,
31  'operator' => null,
32  'value' => '1',
33  'is_value_processed' => null,
34  'aggregator' => 'all',
35  'conditions' => [
36  [
37  'type' => Magento\SalesRule\Model\Rule\Condition\Product::class,
38  'attribute' => 'quote_item_price',
39  'operator' => '==',
40  'value' => '7',
41  'is_value_processed' => false,
42  ]
43  ]
44  ]
45  ],
46  'is_advanced' => 1,
47  'simple_action' => 'by_percent',
48  'discount_amount' => 0,
49  'stop_rules_processing' => 0,
50  'discount_qty' => 0,
51  'discount_step' => 0,
52  'apply_to_shipping' => 1,
53  'times_used' => 0,
54  'is_rss' => 1,
55  'use_auto_generation' => 0,
56  'uses_per_coupon' => 0,
57  'simple_free_shipping' => 2,
58 
59  'website_ids' => [
61  \Magento\Store\Model\StoreManagerInterface::class
62  )->getWebsite()->getId()
63  ]
64  ];
65 $salesRule->loadPost($row);
66 $salesRule->save();