classes/XLite/Model/Shipping/Markup.php line 30

Open in your IDE?
  1. <?php
  2. /**
  3.  * Copyright (c) 2011-present Qualiteam software Ltd. All rights reserved.
  4.  * See https://www.x-cart.com/license-agreement.html for license details.
  5.  */
  6. namespace XLite\Model\Shipping;
  7. use Doctrine\ORM\Mapping as ORM;
  8. /**
  9.  * Shipping markup model
  10.  *
  11.  * @ORM\Entity
  12.  * @ORM\Table (name="shipping_markups",
  13.  *      indexes={
  14.  *          @ORM\Index (name="rate", columns={"method_id","zone_id","min_weight","min_total","min_discounted_total","min_items"}),
  15.  *          @ORM\Index (name="max_weight", columns={"max_weight"}),
  16.  *          @ORM\Index (name="max_total", columns={"max_total"}),
  17.  *          @ORM\Index (name="max_discounted_total", columns={"max_discounted_total"}),
  18.  *          @ORM\Index (name="max_items", columns={"max_items"}),
  19.  *          @ORM\Index (name="markup_flat", columns={"markup_flat"}),
  20.  *          @ORM\Index (name="markup_per_item", columns={"markup_per_item"}),
  21.  *          @ORM\Index (name="markup_percent", columns={"markup_percent"}),
  22.  *          @ORM\Index (name="markup_per_weight", columns={"markup_per_weight"})
  23.  *      }
  24.  * )
  25.  */
  26. class Markup extends \XLite\Model\AEntity
  27. {
  28.     public const INFINITY_VALUE 999999999;
  29.     /**
  30.      * A unique ID of the markup
  31.      *
  32.      * @var integer
  33.      *
  34.      * @ORM\Id
  35.      * @ORM\GeneratedValue (strategy="AUTO")
  36.      * @ORM\Column (type="integer")
  37.      */
  38.     protected $markup_id;
  39.     /**
  40.      * Markup condition: min weight of products in the order
  41.      *
  42.      * @var float
  43.      *
  44.      * @ORM\Column (type="decimal", precision=14, scale=4)
  45.      */
  46.     protected $min_weight 0;
  47.     /**
  48.      * Markup condition: max weight of products in the order
  49.      *
  50.      * @var float
  51.      *
  52.      * @ORM\Column (type="decimal", precision=14, scale=4)
  53.      */
  54.     protected $max_weight self::INFINITY_VALUE;
  55.     /**
  56.      * Markup condition: min order subtotal
  57.      *
  58.      * @var float
  59.      *
  60.      * @ORM\Column (type="decimal", precision=14, scale=2)
  61.      */
  62.     protected $min_total 0;
  63.     /**
  64.      * Markup condition: max order subtotal
  65.      *
  66.      * @var float
  67.      *
  68.      * @ORM\Column (type="decimal", precision=14, scale=2)
  69.      */
  70.     protected $max_total self::INFINITY_VALUE;
  71.     /**
  72.      * Markup condition: min discounted order subtotal
  73.      *
  74.      * @var float
  75.      *
  76.      * @ORM\Column (type="decimal", precision=14, scale=2)
  77.      */
  78.     protected $min_discounted_total 0;
  79.     /**
  80.      * Markup condition: max discounted order subtotal
  81.      *
  82.      * @var float
  83.      *
  84.      * @ORM\Column (type="decimal", precision=14, scale=2)
  85.      */
  86.     protected $max_discounted_total self::INFINITY_VALUE;
  87.     /**
  88.      * Markup condition: min product items in the order
  89.      *
  90.      * @var float
  91.      *
  92.      * @ORM\Column (type="decimal", precision=14, scale=0)
  93.      */
  94.     protected $min_items 0;
  95.     /**
  96.      * Markup condition: max product items in the order
  97.      *
  98.      * @var float
  99.      *
  100.      * @ORM\Column (type="decimal", precision=14, scale=0)
  101.      */
  102.     protected $max_items self::INFINITY_VALUE;
  103.     /**
  104.      * Markup value: flat rate value
  105.      *
  106.      * @var float
  107.      *
  108.      * @ORM\Column (type="decimal", precision=14, scale=2)
  109.      */
  110.     protected $markup_flat 0;
  111.     /**
  112.      * Markup value: percent value
  113.      *
  114.      * @var float
  115.      *
  116.      * @ORM\Column (type="decimal", precision=14, scale=2)
  117.      */
  118.     protected $markup_percent 0;
  119.     /**
  120.      * Markup value: flat rate value per product item
  121.      *
  122.      * @var float
  123.      *
  124.      * @ORM\Column (type="decimal", precision=14, scale=2)
  125.      */
  126.     protected $markup_per_item 0;
  127.     /**
  128.      * Markup value: flat rate value per weight unit
  129.      *
  130.      * @var float
  131.      *
  132.      * @ORM\Column (type="decimal", precision=14, scale=2)
  133.      */
  134.     protected $markup_per_weight 0;
  135.     /**
  136.      * Shipping method (relation)
  137.      *
  138.      * @var \XLite\Model\Shipping\Method
  139.      *
  140.      * @ORM\ManyToOne  (targetEntity="XLite\Model\Shipping\Method", inversedBy="shipping_markups")
  141.      * @ORM\JoinColumn (name="method_id", referencedColumnName="method_id", onDelete="CASCADE")
  142.      */
  143.     protected $shipping_method;
  144.     /**
  145.      * Zone (relation)
  146.      *
  147.      * @var \XLite\Model\Zone
  148.      *
  149.      * @ORM\ManyToOne  (targetEntity="XLite\Model\Zone", inversedBy="shipping_markups", cascade={"merge"})
  150.      * @ORM\JoinColumn (name="zone_id", referencedColumnName="zone_id", onDelete="CASCADE")
  151.      */
  152.     protected $zone;
  153.     /**
  154.      * Calculated markup value
  155.      *
  156.      * @var float
  157.      */
  158.     protected $markupValue 0;
  159.     /**
  160.      * getMarkupValue
  161.      *
  162.      * @return float
  163.      */
  164.     public function getMarkupValue()
  165.     {
  166.         return $this->markupValue;
  167.     }
  168.     /**
  169.      * setMarkupValue
  170.      *
  171.      * @param integer $value Markup value
  172.      *
  173.      * @return void
  174.      */
  175.     public function setMarkupValue($value)
  176.     {
  177.         $this->markupValue $value;
  178.     }
  179.     /**
  180.      * Has rates
  181.      *
  182.      * @return boolean
  183.      */
  184.     public function hasRates()
  185.     {
  186.         return true;
  187.     }
  188.     /**
  189.      * Returns weight range
  190.      *
  191.      * @return array
  192.      */
  193.     public function getWeightRange()
  194.     {
  195.         return [
  196.             $this->getMinWeight(),
  197.             $this->getMaxWeight() == static::INFINITY_VALUE html_entity_decode('&#x221E;') : $this->getMaxWeight()
  198.         ];
  199.     }
  200.     /**
  201.      * Set weight range
  202.      *
  203.      * @param array $value value
  204.      *
  205.      * @return array
  206.      */
  207.     public function setWeightRange($value)
  208.     {
  209.         if (is_array($value)) {
  210.             $this->setMinWeight($value[0]);
  211.             $this->setMaxWeight($value[1] === html_entity_decode('&#x221E;') ? static::INFINITY_VALUE $value[1]);
  212.         }
  213.     }
  214.     /**
  215.      * Returns subtotal range
  216.      *
  217.      * @return array
  218.      */
  219.     public function getSubtotalRange()
  220.     {
  221.         return [
  222.             $this->getMinTotal(),
  223.             $this->getMaxTotal() == static::INFINITY_VALUE html_entity_decode('&#x221E;') : $this->getMaxTotal()
  224.         ];
  225.     }
  226.     /**
  227.      * Set subtotal range
  228.      *
  229.      * @param array $value value
  230.      *
  231.      * @return array
  232.      */
  233.     public function setSubtotalRange($value)
  234.     {
  235.         if (is_array($value)) {
  236.             $this->setMinTotal($value[0]);
  237.             $this->setMaxTotal($value[1] === html_entity_decode('&#x221E;') ? static::INFINITY_VALUE $value[1]);
  238.         }
  239.     }
  240.     /**
  241.      * Returns discounted subtotal range
  242.      *
  243.      * @return array
  244.      */
  245.     public function getDiscountedSubtotalRange()
  246.     {
  247.         return [
  248.             $this->getMinDiscountedTotal(),
  249.             $this->getMaxDiscountedTotal() == static::INFINITY_VALUE html_entity_decode('&#x221E;') : $this->getMaxDiscountedTotal()
  250.         ];
  251.     }
  252.     /**
  253.      * Set discounted subtotal range
  254.      *
  255.      * @param array $value value
  256.      *
  257.      * @return array
  258.      */
  259.     public function setDiscountedSubtotalRange($value)
  260.     {
  261.         if (is_array($value)) {
  262.             $this->setMinDiscountedTotal($value[0]);
  263.             $this->setMaxDiscountedTotal($value[1] === html_entity_decode('&#x221E;') ? static::INFINITY_VALUE $value[1]);
  264.         }
  265.     }
  266.     /**
  267.      * Returns items range
  268.      *
  269.      * @return array
  270.      */
  271.     public function getItemsRange()
  272.     {
  273.         return [
  274.             $this->getMinItems(),
  275.             $this->getMaxItems() == static::INFINITY_VALUE html_entity_decode('&#x221E;') : $this->getMaxItems()
  276.         ];
  277.     }
  278.     /**
  279.      * Set items range
  280.      *
  281.      * @param array $value value
  282.      *
  283.      * @return array
  284.      */
  285.     public function setItemsRange($value)
  286.     {
  287.         if (is_array($value)) {
  288.             $this->setMinItems($value[0]);
  289.             $this->setMaxItems($value[1] === html_entity_decode('&#x221E;') ? static::INFINITY_VALUE $value[1]);
  290.         }
  291.     }
  292.     /**
  293.      * Get markup_id
  294.      *
  295.      * @return integer
  296.      */
  297.     public function getMarkupId()
  298.     {
  299.         return $this->markup_id;
  300.     }
  301.     /**
  302.      * Set min_weight
  303.      *
  304.      * @param float $minWeight
  305.      * @return Markup
  306.      */
  307.     public function setMinWeight($minWeight)
  308.     {
  309.         $this->min_weight $minWeight;
  310.         return $this;
  311.     }
  312.     /**
  313.      * Get min_weight
  314.      *
  315.      * @return float
  316.      */
  317.     public function getMinWeight()
  318.     {
  319.         return $this->min_weight;
  320.     }
  321.     /**
  322.      * Set max_weight
  323.      *
  324.      * @param float $maxWeight
  325.      * @return Markup
  326.      */
  327.     public function setMaxWeight($maxWeight)
  328.     {
  329.         $this->max_weight $maxWeight;
  330.         return $this;
  331.     }
  332.     /**
  333.      * Get max_weight
  334.      *
  335.      * @return float
  336.      */
  337.     public function getMaxWeight()
  338.     {
  339.         return $this->max_weight;
  340.     }
  341.     /**
  342.      * Set min_total
  343.      *
  344.      * @param float $minTotal
  345.      * @return Markup
  346.      */
  347.     public function setMinTotal($minTotal)
  348.     {
  349.         $this->min_total $minTotal;
  350.         return $this;
  351.     }
  352.     /**
  353.      * Get min_total
  354.      *
  355.      * @return float
  356.      */
  357.     public function getMinTotal()
  358.     {
  359.         return $this->min_total;
  360.     }
  361.     /**
  362.      * Set max_total
  363.      *
  364.      * @param float $maxTotal
  365.      * @return Markup
  366.      */
  367.     public function setMaxTotal($maxTotal)
  368.     {
  369.         $this->max_total $maxTotal;
  370.         return $this;
  371.     }
  372.     /**
  373.      * Get max_total
  374.      *
  375.      * @return float
  376.      */
  377.     public function getMaxTotal()
  378.     {
  379.         return $this->max_total;
  380.     }
  381.     /**
  382.      * Set min_discounted_total
  383.      *
  384.      * @param float $minDiscountedTotal
  385.      * @return Markup
  386.      */
  387.     public function setMinDiscountedTotal($minDiscountedTotal)
  388.     {
  389.         $this->min_discounted_total $minDiscountedTotal;
  390.         return $this;
  391.     }
  392.     /**
  393.      * Get min_discounted_total
  394.      *
  395.      * @return float
  396.      */
  397.     public function getMinDiscountedTotal()
  398.     {
  399.         return $this->min_discounted_total;
  400.     }
  401.     /**
  402.      * Set max_discounted_total
  403.      *
  404.      * @param float $maxDiscountedTotal
  405.      * @return Markup
  406.      */
  407.     public function setMaxDiscountedTotal($maxDiscountedTotal)
  408.     {
  409.         $this->max_discounted_total $maxDiscountedTotal;
  410.         return $this;
  411.     }
  412.     /**
  413.      * Get max_discounted_total
  414.      *
  415.      * @return float
  416.      */
  417.     public function getMaxDiscountedTotal()
  418.     {
  419.         return $this->max_discounted_total;
  420.     }
  421.     /**
  422.      * Set min_items
  423.      *
  424.      * @param float $minItems
  425.      * @return Markup
  426.      */
  427.     public function setMinItems($minItems)
  428.     {
  429.         $this->min_items $minItems;
  430.         return $this;
  431.     }
  432.     /**
  433.      * Get min_items
  434.      *
  435.      * @return float
  436.      */
  437.     public function getMinItems()
  438.     {
  439.         return $this->min_items;
  440.     }
  441.     /**
  442.      * Set max_items
  443.      *
  444.      * @param float $maxItems
  445.      * @return Markup
  446.      */
  447.     public function setMaxItems($maxItems)
  448.     {
  449.         $this->max_items $maxItems;
  450.         return $this;
  451.     }
  452.     /**
  453.      * Get max_items
  454.      *
  455.      * @return float
  456.      */
  457.     public function getMaxItems()
  458.     {
  459.         return $this->max_items;
  460.     }
  461.     /**
  462.      * Set markup_flat
  463.      *
  464.      * @param float $markupFlat
  465.      * @return Markup
  466.      */
  467.     public function setMarkupFlat($markupFlat)
  468.     {
  469.         $this->markup_flat $markupFlat;
  470.         return $this;
  471.     }
  472.     /**
  473.      * Get markup_flat
  474.      *
  475.      * @return float
  476.      */
  477.     public function getMarkupFlat()
  478.     {
  479.         return $this->markup_flat;
  480.     }
  481.     /**
  482.      * Set markup_percent
  483.      *
  484.      * @param float $markupPercent
  485.      * @return Markup
  486.      */
  487.     public function setMarkupPercent($markupPercent)
  488.     {
  489.         $this->markup_percent $markupPercent;
  490.         return $this;
  491.     }
  492.     /**
  493.      * Get markup_percent
  494.      *
  495.      * @return float
  496.      */
  497.     public function getMarkupPercent()
  498.     {
  499.         return $this->markup_percent;
  500.     }
  501.     /**
  502.      * Set markup_per_item
  503.      *
  504.      * @param float $markupPerItem
  505.      * @return Markup
  506.      */
  507.     public function setMarkupPerItem($markupPerItem)
  508.     {
  509.         $this->markup_per_item $markupPerItem;
  510.         return $this;
  511.     }
  512.     /**
  513.      * Get markup_per_item
  514.      *
  515.      * @return float
  516.      */
  517.     public function getMarkupPerItem()
  518.     {
  519.         return $this->markup_per_item;
  520.     }
  521.     /**
  522.      * Set markup_per_weight
  523.      *
  524.      * @param float $markupPerWeight
  525.      * @return Markup
  526.      */
  527.     public function setMarkupPerWeight($markupPerWeight)
  528.     {
  529.         $this->markup_per_weight $markupPerWeight;
  530.         return $this;
  531.     }
  532.     /**
  533.      * Get markup_per_weight
  534.      *
  535.      * @return float
  536.      */
  537.     public function getMarkupPerWeight()
  538.     {
  539.         return $this->markup_per_weight;
  540.     }
  541.     /**
  542.      * Set shipping_method
  543.      *
  544.      * @param \XLite\Model\Shipping\Method $shippingMethod
  545.      * @return Markup
  546.      */
  547.     public function setShippingMethod(\XLite\Model\Shipping\Method $shippingMethod null)
  548.     {
  549.         $this->shipping_method $shippingMethod;
  550.         return $this;
  551.     }
  552.     /**
  553.      * Get shipping_method
  554.      *
  555.      * @return \XLite\Model\Shipping\Method
  556.      */
  557.     public function getShippingMethod()
  558.     {
  559.         return $this->shipping_method;
  560.     }
  561.     /**
  562.      * Set zone
  563.      *
  564.      * @param \XLite\Model\Zone $zone
  565.      * @return Markup
  566.      */
  567.     public function setZone(\XLite\Model\Zone $zone null)
  568.     {
  569.         $this->zone $zone;
  570.         return $this;
  571.     }
  572.     /**
  573.      * Get zone
  574.      *
  575.      * @return \XLite\Model\Zone
  576.      */
  577.     public function getZone()
  578.     {
  579.         return $this->zone;
  580.     }
  581. }