• Resolved Kiouze

    (@kiouze)


    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 !

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Diego

    (@daigo75)

    At the moment there isn’t much developer documentation for the EU VAT Assistant, because experienced developers can read the code documentation and write their own custom code, with little guidance. Users who need a customisation can contact us for a consultation (the revenue from consultation services and support plans is what allows us to keep the EU VAT Assistant free).

    If you wish to retrieve the VAT number stored by the EU VAT Assistant, this should work (code provided as an example, without guarantees or support. I would recommend to test it thoroughly before using it on your live site).

    // Load an instance of the order class introduced by the EU VAT Assistant
    // This class includes helper methods that make it easier to retrieve the
    // data stored by the plugin
    $euva_order = new \Aelia\WC\EU_VAT_Assistant\Order($order->get_id());
    // Get the VAT number
    $vat_number = $euva_order->get_customer_vat_number();
    
    • This reply was modified 7 years, 3 months ago by Diego.
    Thread Starter Kiouze

    (@kiouze)

    Thank you a lot, I’ll take look at the code you provided and try to figure out how the plugin works. Have the nicest of days ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to get the VAT numbered entered by the client in PHP after an order ?’ is closed to new replies.