How to get the VAT numbered entered by the client in PHP after an order ?
-
Hello and thanks for this wonderful plugin,
My question is about extracting the full VAT number from the order after the transaction is done.
I’m working with a home made plugin that transfers all my Woocommerce transactions to a spreadsheet in Google Drive and I’m able to extract all the information I need from Woocommerce to create a bill (it actually works) but I can’t find the php variable that contains the full VAT number entered by the client for the orders and I don’t know how to call it in my plugin.
Here’s an exctract of the code :
function get_data_from_woocommerce($order){ $items = $order->get_items( 'line_item' ); $descriptions = ""; $couts = ""; $quantites = ""; $totals = ""; foreach( $items as $item_id => $item ) { $descriptions .= $item['name'] . "\n"; $couts .= $item['line_subtotal']/$item['qty'] . "€\n"; $quantites .= $item['qty'] . "\n"; $totals .= $item['line_subtotal'] . "€\n"; } $reduction = $order->get_total_discount($ex_tax = true)."€"; $totaltva = $order->get_cart_tax()."€"; $totalttc = $order->get_total()."€"; // THIS IS WHERE I'VE TRIED THIS TO GET THE VAT NUMBER BUT IT FAILS $num_tva_intra = $order->get_full_vat_number(); ///////////////////////////////////////////////// $totalht = $totalttc - $totaltva."€"; $contact_infos = $order->get_address( $type = 'billing' ); $contact = $order->get_billing_first_name(). " ".$order->get_billing_last_name(); $company = $contact_infos['company']; $email = $contact_infos['email']; $tel = $contact_infos['phone']; if (!empty($company)){ $client = $company; } else { $client = $contact; } $adresse = $contact_infos['address_1']." ". $contact_infos['address_2']." ". $contact_infos['postcode']." ". $contact_infos['city']." ". $contact_infos['state']." ". $contact_infos['country']; $numerocommandewoocommerce = $order->get_order_number(); $data = array( 'client' => $client, 'mail' => $email, 'contact' => $contact, 'tel' => $tel, 'date' => date("d/m/y"), 'adresse' => $adresse, 'descriptions' => $descriptions, 'couts' => $couts, 'quantites' => $quantites, 'tvas' => $tvas, 'totals' => $totals, 'reduction' => $reduction, 'totalht' => $totalht, 'totaltva' => $totaltva, 'totalttc' => $totalttc, 'numerocommandewoocommerce' => $numerocommandewoocommerce, 'num_tva_intra' => $num_tva_intra ); // error_log(print_R($data,TRUE)); return $data; }
That is a long question for, I think, a short answer, but I can’t find any documentation for this plugin AND I’m very bad at php so thanks in advance for your time !
- The topic ‘How to get the VAT numbered entered by the client in PHP after an order ?’ is closed to new replies.