Delivery and payment filter

Delivery and payment filter for Shop-Script

Filter delivery & payment methods by any criteria

How conditions work?

To reach the target (hide shipping methods or payment), ll of the conditions or part of them should return true.

Filter works with products from shopping cart. Even if you check the day of the week, the result will be the array of products or nothing.

If after checking all conditions filter returns products, it means that conditions executed successfully and we can hide delivery and payment methods.

Priority of conditions

Conditions are checked according to their priority, not the order.

The priority of conditions (by category):

  1. User, Completed orders, Date and time, Variables, Storefront
  2. Product
  3. Cart

System of conditions

If you created more than one condition, You formed a system of conditions.

The system conditions can be:

  • Strict: all conditions return true.
    From beginning to end filters only one set of products. If filter returns no products, it means that filter will not be executed.
  • Not strict: any of conditions return true.
    Each condition works with full (new) set of products. Conditions don't affect each other.

Group of conditions

Group of conditions offers you the opportunity to combine several systems of conditions. Priority rules remain in each group. The set of input data (products) each time new (full).

Group of condition has the highest priority among all conditions.

Examples

Imagine, the customer is registered user. His shopping cart is:

  • Product A: 5000$/pcs - 5 pcs. Total amount - 25 000$. Weight 3 kg.
  • Product B: 4000р/pcs - 5 pcs. Total amount - 20 000$. Weight 9 kg.
  • Product C: 7000р/pcs - 3 pcs. Total amount - 21 000$. Weight 50 kg.
  • Product D: 10 000р/pcs - 4 pcs. Total amount - 40 000$. Weight 52 kg.

Example 1

Follow the process:

  1. We have strict condition group.

    Input data is 4 products. First will be executed the condition from the second group of priority, then from the third.

    "Product feature Weight >= 50" - means that we filter only those products whose weight more than 50 kg. This is product C and product D. Condition completed.

    "Total sum of features value Weight > 100" - means that the total weight of filtered products must be more than 100kg. Product C + Product D = 50 kg * 3 pcs + 52 kg * 4 pcs = 358 pcs. Condition completed.

    "Total quantity of all products > 5" - let's count quantity of C and D. The value is 7. Condition completed. Group of conditions is completed.
  2. Process other conditions. Input data are 4 products + 2 products, which were returned by group. Because these products are already in the set, then the input remains 4 products.
    NOTE: If the group of conditions would return nothing, then the filter would be failed.
  3. First, the condition will be processed from the first group of priority, then from the third.

    "User category equal Shop" - Condition completed, because we mentioned that the order will be purchased by registered user.

    "Total price of all products > 100 000" - Total price is 106 000$. Condition completed.
  4. All conditions return true. It means that Delivery method "Flat rate" and payment method "PayPal" will be hidden from this user.

IMPORTANT! The shopping cart will be the same. It doesn't depend on filter.

Example 2

Follow the process without group of conditions.

  1. Input data is 4 products.

    The order of processing conditions:

    "User category equal Shop" - Condition completed, because we mentioned that the order will be purchased by registered user.

    "Product feature Weight >= 50" - means that we filter only those products whose weight more than 50 kg. This is product C and product D. Condition completed.

    "Total sum of features value Weight > 100" - means that the total weight of filtered products must be more than 100kg. Product C + Product D = 50 kg * 3 pcs + 52 kg * 4 pcs = 358 pcs. Condition completed.

    "Total quantity of all products > 5" - let's count quantity of C and D. The value is 7. Condition completed. Group of conditions is completed.

    "Total price of all products > 100 000" - Total price of product C and product D is 61 000$. Condition NOT completed.
  2. One of the conditions is not completed. Filter will failed, delivery and payment methods will not be hidden.

IMPORTANT! The shopping cart will be the same. It doesn't depend on filter.