Forum Replies Created

Viewing 1 replies (of 1 total)
  • Szia,

    Nekem egy multivendor k?rnyezethez ezt a kódot is lefejlesztették. Nem hiszem, hogy egy az egyben múk?dik, de talán segít. A kóddal kapcsolatban sajnos nem tudok segíteni. Take it as it is.

    //Autogenerate invoice
    public function on_order_processing($order_id, $old_status, $new_status)
    {
    if($new_status == “cancelled”){

    $order = new WC_Order($order_id);

    //Load billingo API
    $billingo = new Request(array(
    ‘public_key’ => billingo_get_option(‘wc_billingo_public_key’, $order_id),
    ‘private_key’ => billingo_get_option(‘wc_billingo_secret_key’, $order_id)
    ));

    $invoiceID = get_post_meta($order_id, “_wc_billingo_id”,true); //624744337

    try {

    $url = “invoices/{$invoiceID }/cancel”;
    $invoice = $billingo->get($url);

    /*UPDATE CANCEL INVOICE DATA*/

    try {
    $file_name = $billingo->get(“invoices/{$invoice[‘id’]}/code”);
    $file_name = $file_name[‘code’];
    } catch (Exception $e) {
    $response[‘messages’][] = __(‘Nem siker??lt l??trehozni a let??lt??si linket a sz?ˇml?ˇhoz.’, ‘billingo’);
    }

    //Create response
    $szamlaszam = $invoice[‘attributes’][‘invoice_no’];
    if (!$szamlaszam) {
    $szamlaszam = $invoice[‘id’];
    }
    $response[‘invoice_name’] = $szamlaszam;

    //Store as a custom field
    update_post_meta($order_id, ‘_wc_billingo’, $szamlaszam);

    //Update order notes
    $order->add_order_note(__(‘Cancelled – Billingo sz?ˇmla sikeresen l??trehozva. A sz?ˇmla sorsz?ˇma: ‘, ‘wc-billingo’) . $szamlaszam);

    //Store the filename
    update_post_meta($order_id, ‘_wc_billingo_pdf’, $file_name);
    update_post_meta($order_id, ‘_wc_billingo_id’, $invoice[‘id’]);

    update_post_meta($order_id, ‘_wc_billingo_cancel_data’, $invoice);

    /*

    print_r($billingo_vat_ids );

    var_dump($billingo_vat_ids );

    die(“fasfasfasfs”);
    */
    //$order->add_order_note(__(‘Billingo Invoice cancelled ‘, ‘wc-billingo’));

    } catch (Exception $e) {
    error_log($e->getMessage(), true);
    $order->add_order_note(__(‘Billingo Cancelled Request :’, ‘wc-billingo’) . $e->getMessage());
    }

    }

Viewing 1 replies (of 1 total)