sunnysideup /
silverstripe-ecommerce
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | |||
| 4 | /** |
||
| 5 | * This is the first Order Step. |
||
| 6 | * |
||
| 7 | * @authors: Nicolaas [at] Sunny Side Up .co.nz |
||
| 8 | * @package: ecommerce |
||
| 9 | * @sub-package: model |
||
| 10 | * @inspiration: Silverstripe Ltd, Jeremy |
||
| 11 | **/ |
||
| 12 | class OrderStep_Created extends OrderStep implements OrderStepInterface |
||
| 13 | { |
||
| 14 | private static $defaults = array( |
||
|
0 ignored issues
–
show
Comprehensibility
introduced
by
Loading history...
|
|||
| 15 | 'CustomerCanEdit' => 1, |
||
| 16 | 'CustomerCanPay' => 1, |
||
| 17 | 'CustomerCanCancel' => 1, |
||
| 18 | 'Name' => 'Create', |
||
| 19 | 'Code' => 'CREATED', |
||
| 20 | 'ShowAsUncompletedOrder' => 1, |
||
| 21 | ); |
||
| 22 | |||
| 23 | /** |
||
| 24 | *initStep: |
||
| 25 | * makes sure the step is ready to run.... (e.g. check if the order is ready to be emailed as receipt). |
||
| 26 | * should be able to run this function many times to check if the step is ready. |
||
| 27 | * |
||
| 28 | * @see Order::doNextStatus |
||
| 29 | * |
||
| 30 | * @param Order object |
||
| 31 | * |
||
| 32 | * @return bool - true if the current step is ready to be run... |
||
| 33 | **/ |
||
| 34 | public function initStep(Order $order) |
||
| 35 | { |
||
| 36 | return true; |
||
| 37 | } |
||
| 38 | |||
| 39 | /** |
||
| 40 | * Add the member to the order, in case the member is not an admin. |
||
| 41 | * |
||
| 42 | * @param DataObject - $order Order |
||
| 43 | * |
||
| 44 | * @return bool |
||
| 45 | **/ |
||
| 46 | public function doStep(Order $order) |
||
| 47 | { |
||
| 48 | if (!$order->MemberID) { |
||
|
0 ignored issues
–
show
The property
MemberID does not exist on object<Order>. Since you implemented __get, maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. Loading history...
|
|||
| 49 | $member = Member::currentUser(); |
||
| 50 | if ($member) { |
||
| 51 | if (!$member->IsShopAdmin()) { |
||
| 52 | $order->MemberID = $member->ID(); |
||
|
0 ignored issues
–
show
The property
MemberID does not exist on object<Order>. Since you implemented __set, maybe consider adding a @property annotation.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
Since the property has write access only, you can use the @property-write annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. Loading history...
|
|||
| 53 | $order->write(); |
||
| 54 | } |
||
| 55 | } |
||
| 56 | } |
||
| 57 | |||
| 58 | return true; |
||
| 59 | } |
||
| 60 | |||
| 61 | /** |
||
| 62 | * We can run the next step, once any items have been added. |
||
| 63 | * |
||
| 64 | * @see Order::doNextStatus |
||
| 65 | * |
||
| 66 | * @param Order $order |
||
| 67 | * |
||
| 68 | * @return OrderStep | Null (next step OrderStep object) |
||
|
0 ignored issues
–
show
|
|||
| 69 | **/ |
||
| 70 | public function nextStep(Order $order) |
||
| 71 | { |
||
| 72 | if ($order->TotalItems($recalculate = true)) { |
||
| 73 | return parent::nextStep($order); |
||
| 74 | } |
||
| 75 | |||
| 76 | return; |
||
| 77 | } |
||
| 78 | |||
| 79 | /** |
||
| 80 | * Allows the opportunity for the Order Step to add any fields to Order::getCMSFields. |
||
| 81 | * |
||
| 82 | *@param FieldList $fields |
||
| 83 | *@param Order $order |
||
| 84 | * |
||
| 85 | *@return FieldList |
||
| 86 | **/ |
||
| 87 | public function addOrderStepFields(FieldList $fields, Order $order) |
||
| 88 | { |
||
| 89 | $fields = parent::addOrderStepFields($fields, $order); |
||
| 90 | if (!$order->IsSubmitted()) { |
||
| 91 | //LINE BELOW IS NOT REQUIRED |
||
| 92 | $header = _t('OrderStep.SUBMITORDER', 'Submit Order'); |
||
| 93 | $label = _t('OrderStep.SUBMITNOW', 'Submit Now'); |
||
| 94 | $msg = _t('OrderStep.MUSTDOSUBMITRECORD', '<p>Tick the box below to submit this order.</p>'); |
||
| 95 | $problems = array(); |
||
| 96 | if (!$order->getTotalItems()) { |
||
| 97 | $problems[] = 'There are no --- Order Items (products) --- associated with this order.'; |
||
| 98 | } |
||
| 99 | if (!$order->MemberID) { |
||
|
0 ignored issues
–
show
The property
MemberID does not exist on object<Order>. Since you implemented __get, maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. Loading history...
|
|||
| 100 | $problems[] = 'There is no --- Customer --- associated with this order.'; |
||
| 101 | } |
||
| 102 | if (!$order->BillingAddressID) { |
||
|
0 ignored issues
–
show
The property
BillingAddressID does not exist on object<Order>. Since you implemented __get, maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. Loading history...
|
|||
| 103 | $problems[] = 'There is no --- Billing Address --- associated with this order.'; |
||
| 104 | } elseif ($billingAddress = $order->BillingAddress()) { |
||
|
0 ignored issues
–
show
The method
BillingAddress() does not exist on Order. Did you maybe mean getBillingAddressField()?
This check marks calls to methods that do not seem to exist on an object. This is most likely the result of a method being renamed without all references to it being renamed likewise. Loading history...
|
|||
| 105 | $requiredBillingFields = $billingAddress->getRequiredFields(); |
||
| 106 | if ($requiredBillingFields && is_array($requiredBillingFields) && count($requiredBillingFields)) { |
||
| 107 | foreach ($requiredBillingFields as $requiredBillingField) { |
||
| 108 | if (!$billingAddress->$requiredBillingField) { |
||
| 109 | $problems[] = "There is no --- $requiredBillingField --- recorded in the billing address."; |
||
| 110 | } |
||
| 111 | } |
||
| 112 | } |
||
| 113 | } |
||
| 114 | if (count($problems)) { |
||
| 115 | $msg = '<p>You can not submit this order because:</p> <ul><li>'.implode('</li><li>', $problems).'</li></ul>'; |
||
| 116 | } |
||
| 117 | $fields->addFieldToTab('Root.Next', new HeaderField('CreateSubmitRecordHeader', $header, 3), 'ActionNextStepManually'); |
||
| 118 | $fields->addFieldToTab('Root.Next', new LiteralField('CreateSubmitRecordMessage', $msg), 'ActionNextStepManually'); |
||
| 119 | if (!$problems) { |
||
|
0 ignored issues
–
show
The expression
$problems of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using empty($expr) instead to make it clear that you intend to check for an array without elements.
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent. Consider making the comparison explicit by using Loading history...
|
|||
| 120 | $fields->addFieldToTab('Root.Next', new CheckboxField('SubmitOrderViaCMS', $label), 'ActionNextStepManually'); |
||
| 121 | } |
||
| 122 | } |
||
| 123 | |||
| 124 | return $fields; |
||
| 125 | } |
||
| 126 | |||
| 127 | /** |
||
| 128 | * Explains the current order step. |
||
| 129 | * |
||
| 130 | * @return string |
||
| 131 | */ |
||
| 132 | protected function myDescription() |
||
| 133 | { |
||
| 134 | return _t('OrderStep.CREATED_DESCRIPTION', 'During this step the customer creates her or his order. The shop admininistrator does not do anything during this step.'); |
||
| 135 | } |
||
| 136 | } |
||
| 137 |