Skip to main content

Shipping Rules Calculator

Rule Structure and Shipping Option Rules

The rule structure is a flexible framework that generates results by applying 'and', 'or', and 'not' logic operations on specially crafted sets of rules, where an unlimited number of nested sub-rules can be written. While 'or' and 'and' rules should have a 'children' field, the 'not' rule should have a 'child' field. Each special rule also has different fields that it needs to have.

{
"children": [
{
...(rule1)
},
{
"children": [
{
"child": {
...(rule2)
},
"name": "Not Rule",
"slug": "not-rule"
},
{
"child": {
...(rule3)
},
"name": "Not Rule",
"slug": "not-rule"
}
],
"name": "And Rule",
"slug": "and-rule"
}
],
"name": "Or Rule",
"slug": "or-rule"
}

The logical equivalent of the above rule structure can be expressed as:

(rule1 or ((not rule2) and (not rule3)))

This means the shipping option with this rule structure will be shown if either rule1 is satisfied or both rule2 and rule3 are not satisfied simultaneously.

WeightRule

A rule that checks if the individual weights of all items in the cart are less than or equal to the specified maximum value.

{ 
"weight_field": "the product attribute name containing the weight value",
"max_weight": 10 (maximum product weight value),
"name": "Weight Rule",
"slug": "weight-rule"
}

HeightRule

A rule that ensures the individual lengths of all items in the cart are less than or equal to the specified maximum value.

{  
"height_field": "the product attribute name containing the height value",
"max_height": 10 (maximum product height value),
"name": "Weight Rule",
"slug": "Weight-rule"
}

CityRule

Allows for the creation of a rule based on the city information of the shipping address. If shipping is desired to specific cities listed in the 'cities' field, the 'exclude' field can be removed from the rule. If this field is set to True, shipping will be done to cities outside the specified city list. The IDs correspond to the city IDs in the database.

{
"cities": [
id1,
id2
],
"exclude": True,
"name": "City Rule",
"slug": "City-rule"
}

CountryRule

Enables the creation of a rule based on the country information of the shipping address. If shipping is desired to specific countries listed in the 'countries' field, the 'exclude' field can be removed from the rule. If this field is set to True, shipping will be done to countries outside the specified country list. The IDs correspond to the country IDs in the database.

{
"countries": [
"id1",
"id2"
],
"exclude": true,
"name": "Country Rule",
"slug": "Country-rule"
}

TownshipRule

Facilitates the creation of a rule based on the district information of the shipping address. If shipping is desired to specific districts listed in the 'townships' field, the 'exclude' field can be removed from the rule. If this field is set to True, shipping will be done to districts outside the specified district list. The IDs correspond to the district IDs in the database.

{
"townships": [
id1,
id2
],
"exclude": True,
"name": "Township Rule",
"slug": "Township-rule"
}

DistrictRule

Allows for the creation of a rule based on the neighborhood information of the shipping address. If shipping is desired to specific neighborhoods listed in the 'districts' field, the 'exclude' field can be removed from the rule. If this field is set to True, shipping will be done to neighborhoods outside the specified neighborhood list. The IDs correspond to the neighborhood IDs in the database.

{
"townships": [
id1,
id2
],
"exclude": True,
"name": "Township Rule",
"slug": "Township-rule"
}

TimeRule

Enables the determination of the time interval during which the shipping option will be available.

{
"start_time": "baslangic saati",
"end_time": "bitis saati",
"name": "Time Rule",
"slug": "time-rule"
}

DayOfWeekRule

Allows for the determination of the days on which the shipping option will be visible. Days should be entered in English in the 'days' field.

{
"days": [
"monday",
"tuesday"
],
"name": "Day Of Week Rule",
"slug": "day-of-week-rule"
}

BasketAmountRule

Enables the creation of a rule based on the discounted basket amount. If the discounted basket amount is greater than or equal to the specified 'max_total_amount' value, the shipping option will be displayed.

{
"max_total_amount": 200,
"name": "Basket Amount Rule",
"slug": "basket-amount-rule"
}

TotalProductAmountRule

Allows for the creation of a rule based on the undiscounted total basket amount. If the undiscounted total basket amount is greater than or equal to the specified 'max_total_amount' value, the shipping option will be displayed.

{
"max_total_amount": 200,
"name": "Total Product Amount Rule",
"slug": "total-product-amount-rule"
}

ProductAttributeRule

Enables the creation of a rule based on product attributes. It checks whether all or any of the products in the cart have a certain value for the selected attribute. If 'any' is selected, at least one product must have the specified value for the selected attribute. If 'all' is selected, all products must comply with this rule. According to the following rule, if the value of the 'attribute_1' attribute for all products in the cart is 'value_1', the relevant shipping option is displayed.

{
"attribute_field": "attribute_1",
"attribute_value": "value_1",
"func": "all",
"name": "Product Attribute Rule",
"slug": "product-attribute-rule"
}

RetailStoreRule

This rule ensures that the shipping option only appears when the option for delivery from the retail store is selected.

{
"name": "Retail Store Rule",
"slug": "retail-store-rule"
}

Calculators for Determining Fees for Shipping Options

FixedPriceCalculator

Enables setting a fixed shipping fee for all purchases. It applies only to the shipping option for which the calculator is entered. When entered in this way, shipping promotions are not considered.

{
"fixed_price": 9.9,
"name": "Fixed Price Calculator",
"slug": "fixed-price-calculator"
}

AmountBasedCalculator

Enables the determination of shipping fees based on the basket total. If the basket total is less than the specified upper limit, it provides the fixed shipping fee; otherwise, it provides the discounted price. When entered in this way, shipping promotions are not considered.

{
"upper_limit": 500,
"fixed_price": 9.9,
"discount_price": 4.9,
"name": "Amount Based Calculator",
"slug": "amount-based-calculator"
}

DiscountBasedCalculator

Enables the calculation of shipping fees considering shipping promotions. If the shipping discount condition is met, the shipping fee will be as determined in the campaign; otherwise, the shipping fee generated by the calculator entered with 'base_shipping' is shown.

{
"base_shipping": "fixed-price-calculator",
"fixed_price": "9.9",
"name": "Discount Based Calculator",
"slug": "discount-based-calculator"
}