$data['status'] = 'new';
$data['locale'] = 'fr';
$data['products'] = [];
- $productsMessage = ['Produits : (reférence : quantité) )'];
+ $productsMessage = ["Produits : \n----"];
+
$index = 0;
$indexMessage = 0;
foreach ($cartData as $id => $_data) {
$indexMessage++;
- $optionsPrices = Product::optionPrice($id, $cartData_[$index]['ref'], $productsArray);
+ $optionsPrices = Product::optionPrice($id, $cartData_[$index]['ref'], $productsArray, true);
$basicSellingPrice = $products[$id]['basic_selling_price'];
$data['products'][] = [
'reference' => $cartData_[$index]['ref'],
'name' => $products[$id]['name'],
'quantity' => $_data,
- 'price' => floatval($basicSellingPrice) ?? 0
+ 'price' => floatval($basicSellingPrice)." €" ?? 0
];
- $productsMessage[] = '|'.$cartData_[$index]['ref'] . ' : ' . $_data . ' ';
+ $productsMessage[] = 'Référence : ' . $cartData_[$index]['ref'] . "\n";
+ $productsMessage[$indexMessage] .= 'Qté : ' . $_data . "\n";
+
+ foreach ($optionsPrices[1] as $v) {
+ $productsMessage[$indexMessage] .= $v . "\n";
+ }
+
+ $labelPrice = 'Prix unitaire HT : ';
if($optionsPrices) {
- $totalOptionPrice = Product::totalOptionPrice($optionsPrices,$cartData_[$index]['ref']);
+ $totalOptionPrice = Product::totalOptionPrice($optionsPrices[0],$cartData_[$index]['ref']);
$data['products'][$index]['price'] = floatval($basicSellingPrice + $totalOptionPrice);
-
- $productsMessage[$indexMessage] .= ' - '.$data['products'][$index]['price'] . '€ HT';
+ $labelPrice = 'Prix unitaire HT (avec options) : ';
}
- $productsMessage[$indexMessage] .= '('.url("/{$products[$id]['slug']}").')';
+
+ $productsMessage[$indexMessage] .= $labelPrice.$data['products'][$index]['price'] . "€ \n";
+
+ $productsMessage[$indexMessage] .= url("/{$products[$id]['slug']}")."\n";
+ $productsMessage[$indexMessage] .= "----";
$index++;
}
return $ids;
}
- public static function priceByQuantity($data) {
-
- }
-
- public static function optionPrice($id, $refs, $productsInfosBase) {
+ public static function optionPrice($id, $refs, $productsInfosBase, $mailCondition = false) {
$opt = [];
+ $optDetails = [];
$explodeRef = explode("|", $refs);
$key -= 1;
if ($key > -1) {
$options_ = $options[$key]['options'];
+ dump($options_);
foreach ($options_ as $opt_) {
+ dump($opt_);
if ($opt_["ref"] === $ref) {
$opt[$refs][] = $opt_["sale_price"] ?? 0;
+ $optDetails[] = ucfirst($options[$key]['name_fr']) . ' : ' . $ref;
}
}
}
}
}
+ if($mailCondition)
+ return [$opt, $optDetails];
+
return $opt;
}
$this->addField(['name' => 'products',
'label' => 'Produits',
'type' => 'Table',
- 'columns' => ['id' => '#', 'reference' => 'Référence', 'name' => 'Nom de produit', 'quantity' => 'Quantité'],
+ 'columns' => [
+ 'id' => '#',
+ 'reference' => 'Référence',
+ 'name' => 'Nom de produit',
+ 'quantity' => 'Quantité',
+ 'price' => 'Prix HT'
+ ],
'tab' => $tabrequest]);
$this->addField(['name' => 'message',