Skip to main content
Coding guidelines
- For SQL statement, when using GROUP_CONCAT it's highly recommended to use | as separator. Because by default, most database use comma as a separator. When raw data is used for csv output; column cannot contain comma.
For example, instead of
SELECT GROUP_CONCAT(order_id) -- which yield 3,5,7 -> breaks the CSV download
we should do
SLECT GROUP_CONCAT(order_id SEPARATOR '|') -- which yields 3|5|7 -> does not break for the CSV download
- To check if a value exists, use if ($value !== null)
Do not use if ($value)
because when $value is zero, if ($value) does not pass.
Example code:
if($quote->getIsMultiShipping() && $quoteItem->getCustomPrice()) {
$item->setPrice($quoteItem->getCustomPrice())->setBaseOriginalPrice($quoteItem->getCustomPrice());
This code is wrong. When customPrice is zero (no-charge), this if statement does not pass.
Rewrite it to this:
if($quote->getIsMultiShipping() && ($quoteItem->getCustomPrice() !== null)) {
$item->setPrice($quoteItem->getCustomPrice())->setBaseOriginalPrice($quoteItem->getCustomPrice());
now, if customPrice is zero, this if statement passes