$discount = Product::calculateDiscount($price_uvp, $price_selling); $net_price = Product::calculateNetPrice($price_selling, VAT); $profit = Product::calculateProfit($net_price, $cogs); $margin = Product::calculateMargin($profit, $net_price); $premium = Product::calculatePremium($price_selling, $cogs); } else { if ($sp_type == 'B2B-ND') { $factor = Product::calculateFactor($price_uvp, $price_selling); $discount = 0; $net_price = $price_selling; $profit = Product::calculateProfit($net_price, $cogs); $margin = Product::calculateMargin($profit, $net_price); $premium = Product::calculatePremium($price_selling, $cogs); } else { $factor = Product::calculateFactor($price_uvp, $price_selling); $discount = Product::calculateDiscount($b2b_price_selling_old, $price_selling); $net_price = $price_selling; $profit = Product::calculateProfit($net_price, $cogs); $margin = Product::calculateMargin($profit, $net_price); $premium = Product::calculatePremium($price_selling, $cogs); } } $margin_text = Product::displayMargin($price_selling, $margin); $result = array(); $result['target_id'] = $target_id; $result['column_count'] = $column_count; $result['factor'] = $factor == 0 ? '-' : $factor; $result['discount'] = $discount == 0 ? '-' : $discount . '%'; $result['cogs'] = $cogs; $result['profit'] = $profit; $result['margin'] = $margin_text;
/** * Process Zalora BMP Catalog Cell Values * @global products_brand $class_pb * @global Int $jng_sp_id * @global Array $sp_detail * @global type $sp_values_brand * @global type $sp_values_colors * @global type $sp_values_navcat * @global type $sp_values_navsubcat * @global type $category_top_id * @param type $column_key * @param type $product * @param type $aid * @return string */ function getZaloraBMPCatalogCellValue($column_key, $product, $aid, $row_number) { global $class_pb, $class_pm, $jng_sp_id, $sp_detail, $sp_values_brand, $sp_values_colors, $sp_values_navcat, $sp_values_navsubcat, $category_top_id, $cat_zalorabmp, $sub_cat_zalorabmp; $lid = $sp_detail['languages_id']; if (!isset($sp_values_brand[$product->brand_id])) { $sp_brands = $class_pb->getSPbrands($product->brand_id); $sp_values_brand[$product->brand_id] = $sp_brands[$jng_sp_id]; } $product_old_function = $product->getOldProductFunction()->retrieveDetail($product->id, 'p,pd,pd2,pc,pnc,cat,pei,pci'); $category_id = $product->category_id; switch ($column_key) { case 'NO': $value = $row_number; break; case 'SEASON': $value = 'Year round'; break; case 'YEAR': $value = date('Y'); break; case 'M/F': $value = ucwords($class_pm->productGenderName($product->getProductGenderID())); break; case 'CATEGORY': $param_key = $product->getCategory()->id . '-' . $product->getProductGenderID(); $value = $cat_zalorabmp[$sp_values_navcat[$param_key]]; break; case 'SUB CATEGORY': $param_key = $product->getSubCategory() . '-' . $product->getProductGenderID(); $value = $sub_cat_zalorabmp[$sp_values_navsubcat[$param_key]]; break; case 'SELLER SKU': $value = $product->code; break; case 'PRODUCT NAME': //Always get english name if ($category_top_id == '1') { //JEWELRY $value = $product_old_function['pd'][1]['products_name']; } else { $value = $product->getNameRaw(1); } break; case 'SUPPLIER COLOR NAME': $value = $product->getColors(1); break; case 'DESCRIPTION': $value = $product->getDescription($lid); break; case 'COMPOSITION': $value = ucfirst(strtolower(ProductAttribute::displayAttributeName($product->id, ProductAttribute::GROUP_ID_COMPOSITION, $lid, ' '))); break; case 'MEASUREMENT': //jewelry if ($category_top_id == 1) { $value = $product->displayMeasurement(3, $aid, '', Product::FORMAT_DISPLAYMEASUREMENT_PM2, '.'); } else { if ($aid == '0') { //grab all measurement one time only when loop indicated for default article $value = $product->displayMeasurement(3, $aid, '', Product::FORMAT_DISPLAYMEASUREMENT_AM4, '.'); } } break; case 'CARE INSTRUCTIONS': $value = ucfirst(strtolower(ProductAttribute::displayAttributeName($product->id, ProductAttribute::GROUP_ID_CARELABEL, $lid))); break; case 'RETAIL PRICE': $price = $product->getPriceSelling($jng_sp_id); $price_old = $product->getPriceSellingOld($jng_sp_id); if ($price_old <= $price) { $price_old = $price; } $value = $price_old; break; case 'MARGIN%': $price = $product->getPriceSelling($jng_sp_id); $price_old = $product->getPriceSellingOld($jng_sp_id); $discount = ''; if ($price <= $price_old) { $discount = Product::calculateDiscount($price_old, $price); } $value = "{$discount}%"; break; case 'SPECIAL PRICE': $price = $product->getPriceSelling($jng_sp_id); $price_old = $product->getPriceSellingOld($jng_sp_id); if ($price_old <= $price) { //show blank if its not discounted $price = ''; } $value = $price; break; case 'FREE': //"One size" stock will filled in this column //"One size" stock will filled in this column case 'S': case 'M': case 'L': case 'XL': case '4.8': case '5': case '5.2': case '5.4': case '5.6': case '5.8': case '17': case '18': case '19': case '20': case '21': case '22': case '23': case '24': case '25': case '26': case '27': case '28': case '29': case '30': case '31': case '32': case '33': case '34': case '35': case '36': case '37': case '38': case '39': case '40': case '41': case '42': case '43': case '44': case '45': case '46': case '47': case '48': case '49': case '50': case '60': case '65': case '70': case '80': case '90': case '100': case '120': $value = getZaloraBMPStockValue($column_key, $product, $aid); break; case 'DELIVERY DATE': $value = ''; break; case 'ARRIVAL DATE': $value = ''; break; case 'SIZE SENT': //Sent Default Size /* $default_length = $product->articles[0]['length']; if (Product::isUsingSizeInsteadOfLength($product->category_id)) { $sizes = getLength2Sizes(); $size = $sizes[$default_length]; } else { $size = $default_length; } $value = $size; */ $value = ''; break; default: $value = ''; } return $value; }