Function to generate cart price rule
public function generateCoupon($value='')
{
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$coupon['name'] = 'PROMO1';
$coupon['desc'] = 'Promotion one';
$coupon['start'] = date('Y-m-01');
$coupon['end'] = date('Y-m-t');
$coupon['max_redemptions'] = 1;
$coupon['discount_type'] = 'by_percent';
$coupon['discount_amount'] = 30;
$coupon['flag_is_free_shipping'] = 'no';
$coupon['redemptions'] = 1;
$coupon['code'] = "PROMOPROMO2";
$coupon['store_labels'] = '3k-4.9k 30% discount'; //this code will normally be autogenetated but i am hard coding for testing purposes
$shoppingCartPriceRule = $objectManager->create('Magento\SalesRule\Model\Rule');
$shoppingCartPrice = $shoppingCartPriceRule->setName($coupon['name'])
->setDescription($coupon['desc'])
->setFromDate($coupon['start'])
->setToDate($coupon['end'])
->setUsesPerCustomer($coupon['max_redemptions'])
->setCustomerGroupIds(array('1',))
->setIsActive(1)
->setSimpleAction($coupon['discount_type'])
->setDiscountAmount($coupon['discount_amount'])
->setDiscountQty(1)
->setApplyToShipping($coupon['flag_is_free_shipping'])
->setTimesUsed($coupon['redemptions'])
->setStoreLabels(array('40% Discount For First Order','40% Discount For First Order'))
->setWebsiteIds(array('1'))
->setCouponType(2)
->setCouponCode($coupon['code'])
->setUsesPerCoupon(NULL);
$shoppingCartPriceRule->save();}
The above function create coupon code successfully. But there is a condition, I have to add a condition that order amount is greater than 5000. Then only coupon is accessible. How can i add this condition?