delivery stiker - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.



Your result can be seen below.

Result of php executing





Full code of delivery stiker.php

  1. <?php
  2. function get_free_delivery($item)
  3. {
  4.     if($item['id'] == 21912) return false;
  5.  
  6.     if(!in_array($item['group_id'], array(1, 2, 3, 4, 5, 11, 15, 25, 27)))
  7.         return false;
  8.     if($item['instock_warehouse'] != NULL && ($item['margin']??0)>2000)
  9.         return true;
  10.  
  11.     if(in_array($item["manufacturer"], array("Искра", "ИТС", "Сэлма", "ЭТА", "ЭСВА")))
  12.         return false;
  13.  
  14.     if ($item["weight"] > 200)
  15.         return false;
  16.  
  17.     if ($item["weight"] == NULL)
  18.         return false;
  19.  
  20.     if(in_array($item['group_id'], array(1, 2, 3, 4, 5, 27))) {
  21.         if ($item["margin"] > 3000)
  22.             return true;
  23.  
  24.         if ($item["margin"] > 2000 && in_array($item["manufacturer"], array("Сварог", "Aurora", "Triton", "Gazvolt", "EWM", "GasIQ", "Blueweld", "Fubag", "Endress", "Translas", "Abac", "Comaro", "Kraftmann")))
  25.             return true;
  26.     }
  27.  
  28.     if($item['group_id'] == 11 || $item['group_id'] == 15) { //generators - Генераторы
  29.         if ($item["weight"] < 50 && $item["margin"] >= 5000) {
  30.             $delivery = true;
  31.         } elseif ($item["weight"] < 81 && $item["margin"] >= 8000) {
  32.             $delivery = true;
  33.         } elseif ($item["weight"] < 100 && $item["margin"] >= 10000) {
  34.             $delivery = true;
  35.         } elseif ($item["weight"] < 150 && $item["margin"] >= 16000) {
  36.             $delivery = true;
  37.         } elseif ($item["weight"] < 200 && $item["margin"] >= 22000) {
  38.             $delivery = true;
  39.         } elseif ($item["weight"] < 250 && $item["margin"] >= 28000) {
  40.             $delivery = true;
  41.         } elseif ($item["weight"] < 300 && $item["margin"] >= 34000) {
  42.             $delivery = true;
  43.         } elseif ($item["weight"] == 0) {
  44.             $delivery = false;
  45.         } elseif ($item["margin"] == 0) {
  46.             $delivery = false;
  47.         } else {
  48.             $delivery = false;
  49.         }
  50.         return $delivery;
  51.     }
  52.  
  53.     if($item['group_id'] == 25) return true;
  54.  
  55.     return false;
  56. }
  57.  
File Description
  • delivery stiker
  • PHP Code
  • 18 Feb-2020
  • 1.94 Kb
You can Share it: