0

In Woocommerce, I have created a custom cart with different calculated tax and new total.

How can I send the email with this new data?
In what file of Woocommerce?

<?php 
global $woocommerce;
$items = $woocommerce->cart->get_cart();
foreach($items as $item => $values) { 
    $product =wc_get_product( $values['data']->get_id()); 
    echo "<b>".$product->get_title().'</b><br> Quantità: '.$values['quantity'].'<br>'; 
    $price = get_post_meta($values['product_id'] , '_price', true);
    echo "Prezzo: ".$price."<br>";
    $carrello = $values['quantity'] * $price;
    echo "Totale: ".$carrello."<br>";

   // Below the new data with tax and discount calculation:

    $percent = ($tax_amount / $without_tax) * 100;
    if ($percent == "10") 
        $tax_rate = 10; 
    else $tax_rate= 4;
        $with_tax = $scontato; 

    $totaleforsebene = ($scontato * $percent)/100; 
    $totalForSebeneArray[$values['data']->get_id()] = $totaleforsebene; // add the value by the item ID
    $totaleforsebene = number_format($totaleforsebene, 2, '.', '')." €"; 
}
?>
<th>Iva<br />Totale chiusura</th>
<td>
<?php 
$totaleiva_1 = 0;
$items = $woocommerce->cart->get_cart();
foreach($items as $item ) {
    $totaleiva_1 += $totalForSebeneArray[$item ['data']->get_id()];
}
$totaleiva_1 = number_format($totaleiva_1, 2, '.', '');
echo "&euro;"; echo $totaleiva_1;
echo "<br>";
$totalefinitocarrello = $totaleiva_1 + $total;
echo "&euro;"; echo $totalefinitocarrello;
?></td></tr>
<?php endif; ?>
LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399
  • **You can't send an email related to your new data** as the email notifications are made with related `WC_Order` data, but not with `WC_Cart` data… – LoicTheAztec Mar 07 '19 at 10:26
  • Yes I know. Infact I past the code of cart total. How can I pass this code in order? Thank you – Rosanna La Malfa Mar 07 '19 at 10:36
  • It is not the right way to do that and what you are asking is really too broad and complicated… So sorry as nobody will answer your question here with what you have made. Also your actual code is outdated. – LoicTheAztec Mar 07 '19 at 10:50
  • Ok sorry. I thinked the best way because so there were all new data. What is the best way? Do I open another post? Thank you for your patience – Rosanna La Malfa Mar 07 '19 at 11:00
  • This is just too complicated and a tutorial like. Remember that *"Questions asking us to recommend or find a book, tool, software library, **tutorial** or other off-site resource are off-topic for Stack Overflow"*. In Stack Overflow people ask **small** question including the shortest necessary code… The community is able to help them… – LoicTheAztec Mar 07 '19 at 12:11
  • Thanks a lot. I open another simpler post – Rosanna La Malfa Mar 07 '19 at 12:17

0 Answers0