1 <?php
2
3 /* --------------------------------------------------------------
4 ProductSettings.inc.php 2016-01-28
5 Gambio GmbH
6 http://www.gambio.de
7 Copyright (c) 2016 Gambio GmbH
8 Released under the GNU General Public License (Version 2)
9 [http://www.gnu.org/licenses/gpl-2.0.html]
10 --------------------------------------------------------------
11 */
12
13 /**
14 * Class ProductSettings
15 *
16 * @category System
17 * @package Product
18 * @subpackage Entities
19 */
20 class ProductSettings implements ProductSettingsInterface
21 {
22 /**
23 * Details template.
24 *
25 * @var string
26 */
27 protected $detailsTemplate = '';
28
29 /**
30 * Option detail template.
31 *
32 * @var string
33 */
34 protected $optionsDetailsTemplate = '';
35
36 /**
37 * Options listing template.
38 *
39 * @var string
40 */
41 protected $optionsListingTemplate = '';
42
43 /**
44 * Show on start page?
45 *
46 * @var bool
47 */
48 protected $showOnStartpage = false;
49
50 /**
51 * Start page sort order.
52 *
53 * @var int
54 */
55 protected $startpageSortOrder = 0;
56
57 /**
58 * Show added time?
59 *
60 * @var bool
61 */
62 protected $showAddedDateTime = false;
63
64 /**
65 * Show quantity info?
66 *
67 * @var bool
68 */
69 protected $showQuantityInfo = false;
70
71 /**
72 * Show weight?
73 *
74 * @var bool
75 */
76 protected $showWeight = false;
77
78 /**
79 * Show price offer?
80 *
81 * @var bool
82 */
83 protected $showPriceOffer = false;
84
85 /**
86 * Price status.
87 *
88 * @var int
89 */
90 protected $priceStatus = 0;
91
92 /**
93 * Minimal order value.
94 *
95 * @var float
96 */
97 protected $minOrder = 0.0;
98
99 /**
100 * Graduated quantity.
101 *
102 * @var float
103 */
104 protected $graduatedQuantity = 0.0;
105
106 /**
107 * Is listed as an entry in the sitemap?
108 *
109 * @var bool
110 */
111 protected $sitemapEntry = false;
112
113 /**
114 * Sitemap entry priority.
115 *
116 * @var string
117 */
118 protected $sitemapPriority = '';
119
120 /**
121 * Sitemap change frequency.
122 *
123 * @var string
124 */
125 protected $sitemapChangeFreq = '';
126
127 /**
128 * Show properties price?
129 *
130 * @var bool
131 */
132 protected $showPropertiesPrice = false;
133
134 /**
135 * Properties dropdown mode.
136 *
137 * @var string
138 */
139 protected $propertiesDropdownMode = '';
140
141 /**
142 * Use properties combination weight?
143 *
144 * @var bool
145 */
146 protected $propertiesCombisWeight = false;
147
148 /**
149 * Use properties combination quantity?
150 *
151 * @var int
152 */
153 protected $propertiesCombisQuantityCheckMode = 0;
154
155 /**
156 * Use properties combination shipping time?
157 *
158 * @var bool
159 */
160 protected $propertiesCombisShippingTime = false;
161
162 /**
163 * Permitted customer status.
164 *
165 * @var array
166 */
167 protected $permittedCustomerStatus = array();
168
169
170 /**
171 * Returns the details template name.
172 *
173 * @return string
174 */
175 public function getDetailsTemplate()
176 {
177 return $this->detailsTemplate;
178 }
179
180
181 /**
182 * Returns the options details template.
183 *
184 * @return string
185 */
186 public function getOptionsDetailsTemplate()
187 {
188 return $this->optionsDetailsTemplate;
189 }
190
191
192 /**
193 * Returns the options listing template.
194 *
195 * @return string
196 */
197 public function getOptionsListingTemplate()
198 {
199 return $this->optionsListingTemplate;
200 }
201
202
203 /**
204 * Returns true when the product is displayed on the start page, false otherwise.
205 *
206 * @return bool
207 */
208 public function showOnStartpage()
209 {
210 return $this->showOnStartpage;
211 }
212
213
214 /**
215 * Returns the sort position of the startpage.
216 *
217 * @return int
218 */
219 public function getStartpageSortOrder()
220 {
221 return $this->startpageSortOrder;
222 }
223
224
225 /**
226 * Returns true when the added date time is to be displayed, false otherwise.
227 *
228 * @return bool
229 */
230 public function showAddedDateTime()
231 {
232 return $this->showAddedDateTime;
233 }
234
235
236 /**
237 * Returns true when the quantity info is to be displayed, false otherwise.
238 *
239 * @return bool
240 */
241 public function showQuantityInfo()
242 {
243 return $this->showQuantityInfo;
244 }
245
246
247 /**
248 * Returns true when the weight is to be displayed, false otherwise.
249 *
250 * @return bool
251 */
252 public function showWeight()
253 {
254 return $this->showWeight;
255 }
256
257
258 /**
259 * Returns true when the price offer is to be displayed, false otherwise.
260 *
261 * @return bool
262 */
263 public function showPriceOffer()
264 {
265 return $this->showPriceOffer;
266 }
267
268
269 /**
270 * Returns the price status.
271 *
272 * @return int
273 */
274 public function getPriceStatus()
275 {
276 return $this->priceStatus;
277 }
278
279
280 /**
281 * Returns the minimum order value.
282 *
283 * @return float
284 */
285 public function getMinOrder()
286 {
287 return $this->minOrder;
288 }
289
290
291 /**
292 * Returns the graduated quantity.
293 *
294 * @return float
295 */
296 public function getGraduatedQuantity()
297 {
298 return $this->graduatedQuantity;
299 }
300
301
302 /**
303 * Returns true when the product is to be displayed in the sitemap, false otherwise.
304 *
305 * @return bool
306 */
307 public function isSitemapEntry()
308 {
309 return $this->sitemapEntry;
310 }
311
312
313 /**
314 * Returns the sitemap priority.
315 *
316 * @return string
317 */
318 public function getSitemapPriority()
319 {
320 return $this->sitemapPriority;
321 }
322
323
324 /**
325 * Returns the sitemap change frequency.
326 *
327 * @return string
328 */
329 public function getSitemapChangeFreq()
330 {
331 return $this->sitemapChangeFreq;
332 }
333
334
335 /**
336 * Returns true when the properties price is to be displayed, false otherwise.
337 *
338 * @return bool
339 */
340 public function showPropertiesPrice()
341 {
342 return $this->showPropertiesPrice;
343 }
344
345
346 /**
347 * Returns the properties dropdown mode.
348 *
349 * @return string
350 */
351 public function getPropertiesDropdownMode()
352 {
353 return $this->propertiesDropdownMode;
354 }
355
356
357 /**
358 * Returns true when the properties combis weight is to be used, false otherwise.
359 *
360 * @return bool
361 */
362 public function usePropertiesCombisWeight()
363 {
364 return $this->propertiesCombisWeight;
365 }
366
367
368 /**
369 * Returns the mode which is used for the quantity check.
370 *
371 * 0 = Default (global stock options)
372 * 1 = Products quantity
373 * 2 = Combis quantity
374 * 3 = No check
375 *
376 * @return int
377 */
378 public function getPropertiesCombisQuantityCheckMode()
379 {
380 return $this->propertiesCombisQuantityCheckMode;
381 }
382
383
384 /**
385 * Returns true when the properties combis shipping time is to be used, false otherwise.
386 *
387 * @return bool
388 */
389 public function usePropertiesCombisShippingTime()
390 {
391 return $this->propertiesCombisShippingTime;
392 }
393
394
395 /**
396 * Sets the details listing template.
397 *
398 * @param StringType $template Name of the template
399 *
400 * @return ProductSettings|$this Same ProductSettings instance for chained method calls.
401 */
402 public function setDetailsTemplate(StringType $template)
403 {
404 $this->detailsTemplate = $template->asString();
405
406 return $this;
407 }
408
409
410 /**
411 * Sets the options details template.
412 *
413 * @param StringType $template Name of the template.
414 *
415 * @return ProductSettings|$this Same ProductSettings instance for chained method calls.
416 */
417 public function setOptionsDetailsTemplate(StringType $template)
418 {
419 $this->optionsDetailsTemplate = $template->asString();
420
421 return $this;
422 }
423
424
425 /**
426 * Sets the options listing template.
427 *
428 * @param StringType $template Name of the template.
429 *
430 * @return ProductSettings|$this Same ProductSettings instance for chained method calls.
431 */
432 public function setOptionsListingTemplate(StringType $template)
433 {
434 $this->optionsListingTemplate = $template->asString();
435
436 return $this;
437 }
438
439
440 /**
441 * Determine whether the product is to be displayed on the startpage or not.
442 *
443 * @param BoolType $status True when it is to be displayed, false otherwise.
444 *
445 * @return ProductSettings|$this Same ProductSettings instance for chained method calls.
446 */
447 public function setShowOnStartpage(BoolType $status)
448 {
449 $this->showOnStartpage = $status->asBool();
450
451 return $this;
452 }
453
454
455 /**
456 * Sets the start page sort order.
457 *
458 * @param IntType $sortOrder Sort position.
459 *
460 * @return ProductSettings|$this Same ProductSettings instance for chained method calls.
461 */
462 public function setStartpageSortOrder(IntType $sortOrder)
463 {
464 $this->startpageSortOrder = $sortOrder->asInt();
465
466 return $this;
467 }
468
469
470 /**
471 * Shows or hides the added date time of a product.
472 *
473 * @param BoolType $status True when it is to be displayed, false otherwise.
474 *
475 * @return ProductSettings|$this Same ProductSettings instance for chained method calls.
476 */
477 public function setShowAddedDateTime(BoolType $status)
478 {
479 $this->showAddedDateTime = $status->asBool();
480
481 return $this;
482 }
483
484
485 /**
486 * Shows or hides the quantity info of a product.
487 *
488 * @param BoolType $status True when it is to be displayed, false otherwise.
489 *
490 * @return ProductSettings|$this Same ProductSettings instance for chained method calls.
491 */
492 public function setShowQuantityInfo(BoolType $status)
493 {
494 $this->showQuantityInfo = $status->asBool();
495
496 return $this;
497 }
498
499
500 /**
501 * Shows or hides the weight of a product.
502 *
503 * @param BoolType $status True when it is to be displayed, false otherwise.
504 *
505 * @return ProductSettings|$this Same ProductSettings instance for chained method calls.
506 */
507 public function setShowWeight(BoolType $status)
508 {
509 $this->showWeight = $status->asBool();
510
511 return $this;
512 }
513
514
515 /**
516 * Shows or hides the price offer of a product.
517 *
518 * @param BoolType $status True when it is to be displayed, false otherwise.
519 *
520 * @return ProductSettings|$this Same ProductSettings instance for chained method calls.
521 */
522 public function setShowPriceOffer(BoolType $status)
523 {
524 $this->showPriceOffer = $status->asBool();
525
526 return $this;
527 }
528
529
530 /**
531 * Sets the price status.
532 *
533 * @param IntType $status New price status.
534 *
535 * @return ProductSettings|$this Same ProductSettings instance for chained method calls.
536 */
537 public function setPriceStatus(IntType $status)
538 {
539 $this->priceStatus = $status->asInt();
540
541 return $this;
542 }
543
544
545 /**
546 * Sets the min order value.
547 *
548 * @param DecimalType $quantity New minimum order.
549 *
550 * @return ProductSettings|$this Same ProductSettings instance for chained method calls.
551 */
552 public function setMinOrder(DecimalType $quantity)
553 {
554 $this->minOrder = $quantity->asDecimal();
555
556 return $this;
557 }
558
559
560 /**
561 * Sets the graduated quantity.
562 *
563 * @param DecimalType $quantity New graduated quantity.
564 *
565 * @return ProductSettings|$this Same ProductSettings instance for chained method calls.
566 */
567 public function setGraduatedQuantity(DecimalType $quantity)
568 {
569 $this->graduatedQuantity = $quantity->asDecimal();
570
571 return $this;
572 }
573
574
575 /**
576 * Determine whether the product is to be displayed in the sitemap or not.
577 *
578 * @param BoolType $status True when it is to be displayed, false otherwise.
579 *
580 * @return ProductSettings|$this Same ProductSettings instance for chained method calls.
581 */
582 public function setSitemapEntry(BoolType $status)
583 {
584 $this->sitemapEntry = $status->asBool();
585
586 return $this;
587 }
588
589
590 /**
591 * Sets the sitemap priority.
592 *
593 * @param StringType $priority New sitemap priority.
594 *
595 * @return ProductSettings|$this Same ProductSettings instance for chained method calls.
596 */
597 public function setSitemapPriority(StringType $priority)
598 {
599 $this->sitemapPriority = $priority->asString();
600
601 return $this;
602 }
603
604
605 /**
606 * Sets the sitemap change frequency.
607 *
608 * @param StringType $freq New sitemap change frequency.
609 *
610 * @return ProductSettings|$this Same ProductSettings instance for chained method calls.
611 */
612 public function setSitemapChangeFreq(StringType $freq)
613 {
614 $this->sitemapChangeFreq = $freq->asString();
615
616 return $this;
617 }
618
619
620 /**
621 * Shows or hides the properties price of a product.
622 *
623 * @param BoolType $status True when it is to be displayed, false otherwise.
624 *
625 * @return ProductSettings|$this Same ProductSettings instance for chained method calls.
626 */
627 public function setShowPropertiesPrice(BoolType $status)
628 {
629 $this->showPropertiesPrice = $status->asBool();
630
631 return $this;
632 }
633
634
635 /**
636 * Sets the properties dropdown mode.
637 *
638 * @param StringType $mode New properties dropdown mode.
639 *
640 * @return ProductSettings|$this Same ProductSettings instance for chained method calls.
641 */
642 public function setPropertiesDropdownMode(StringType $mode)
643 {
644 $this->propertiesDropdownMode = $mode->asString();
645
646 return $this;
647 }
648
649
650 /**
651 * Determine whether the properties combis weight is to be used or not.
652 *
653 * @param BoolType $status True when it is to be used, false otherwise.
654 *
655 * @return ProductSettings|$this Same ProductSettings instance for chained method calls.
656 */
657 public function setUsePropertiesCombisWeight(BoolType $status)
658 {
659 $this->propertiesCombisWeight = $status->asBool();
660
661 return $this;
662 }
663
664
665 /**
666 * Determine which mode for the quantity check should be used.
667 *
668 * 0 = Default (global stock options)
669 * 1 = Products quantity
670 * 2 = Combis quantity
671 * 3 = No check
672 *
673 * @param IntType $status
674 *
675 * @return ProductSettings|$this Same ProductSettings instance for chained method calls.
676 */
677 public function setPropertiesCombisQuantityCheckMode(IntType $status)
678 {
679 $this->propertiesCombisQuantityCheckMode = $status->asInt();
680
681 return $this;
682 }
683
684
685 /**
686 * Determine whether the properties combis shipping time is to be used or not.
687 *
688 * @param BoolType $status True when it is to be used, false otherwise.
689 *
690 * @return ProductSettings|$this Same ProductSettings instance for chained method calls.
691 */
692 public function setUsePropertiesCombisShippingTime(BoolType $status)
693 {
694 $this->propertiesCombisShippingTime = $status->asBool();
695
696 return $this;
697 }
698
699
700 /**
701 * Returns true when the customer status is permitted, false otherwise.
702 *
703 * @param IdType $customerStatusId Id of customer status.
704 *
705 * @return bool
706 */
707 public function isPermittedCustomerStatus(IdType $customerStatusId)
708 {
709 return (array_key_exists($customerStatusId->asInt(),
710 $this->permittedCustomerStatus)) ? $this->permittedCustomerStatus[$customerStatusId->asInt()] : false;
711 }
712
713
714 /**
715 * Sets customer status permissions.
716 *
717 * @param IdType $customerStatusId Id of customer status.
718 * @param BoolType $permitted Is customer permitted or not.
719 *
720 * @return ProductSettings|$this Same ProductSettings instance for chained method calls.
721 */
722 public function setPermittedCustomerStatus(IdType $customerStatusId, BoolType $permitted)
723 {
724 $this->permittedCustomerStatus[$customerStatusId->asInt()] = $permitted->asBool();
725
726 return $this;
727 }
728 }