• Resolved CarmineMolisso

    (@byprogrammer)


    Hi, I’m using your plugin in combination with WooCommerce Checkout Manager PRO and I have discovered a bug that appears generating invoices with multiple selections in Woocommerce orders backend page.
    This is the problem: I have created some additional fields on my checkout and they are correctly inserted at the end of the document, but if I select more orders and on one order ALL the additional fields are compiled while on the other orders, not all the fields are compiled, in the invoices of these orders are printed the data inserted in the previous order.

    Let’s make an example: I have these three additional fields “Field_1”, “Field_2”, “Field_3”. And I select these orders:
    ORDER 1: User compiled the “Field_1”, “Field_2”, “Field_3”;
    ORDER 2: User compiled only the “Field_1”;
    ORDER 3: User compiled only the “Field_1” and “Field_2”;

    In the document (invoice) of order 2 are printed the Field_2 and Field_3 of Order 1 and in the document (invoice) of order 3 is printed the Field_3 of User 1.

    <b>So, when you print additional fields on the document (for multi-select orders and invoice print group action), you don’t clear the variables. </b>

    Can you check it?
    Thanks

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Contributor kluver

    (@kluver)

    Hi @byprogrammer,

    Can you tell us how you are adding these custom fields to your invoice? Could you share the code you use?

    Thread Starter CarmineMolisso

    (@byprogrammer)

    Hi, thanks for your replay.
    I’m using the Woocommerce Checkout manager plugin.

    https://it.www.ads-software.com/plugins/woocommerce-checkout-manager/

    Plugin Contributor Ewout

    (@pomegranate)

    That is the plugin you use for the fields in the checkout, but we need to know how you have added them to the invoice. It sounds like you may not be reading them into the invoice correctly, causing the values to get stuck.

    Thread Starter CarmineMolisso

    (@byprogrammer)

    Hi, sorry for the delay.
    I’m not using any plugin or coding part to show these fields in the invoices, but I was supposing that the fields are showed automatically by your plugin. Isn’t this right?

    This is how the fields appear in the invoice: https://www.dropbox.com/s/znrztezhnia5i3k/Schermata%202020-12-17%20alle%2000.26.21.png?dl=0

    Plugin Contributor Ewout

    (@pomegranate)

    Ah that explains. No, these “Order Additional” fields are not coming from our plugin, but they are added by Woocommerce Checkout Manager PRO. This means that if something gets stuck, this will need to be fixed in Woocommerce Checkout Manager PRO.

    Upon checking code in Woocommerce Checkout Manager PRO, I did notice an error, because it seems they are using the order number instead of the order ID (these are not necessarily the same!):

    
    $this->register_invoice_fields($order->get_order_number());
    

    should be:

    
    $this->register_invoice_fields($order->get_id());
    

    But I don’t know if that’s related to your issue. You could certainly mention it when contacting their support. Let us know if there’s anything else you need from us!

    Plugin Contributor Ewout

    (@pomegranate)

    I also found why it’s getting stuck. This code:

    
    if ($value = get_post_meta($order_id, sprintf('_%s', $field['key']), true)) {
      $this->billing_fields[$field['key']] = [
        'key' => $field['key'],
        'label' => $field['label'],
        'value' => $value
      ];
    }
    

    should be adapted to reset the field if it’s not set:

    
    if ($value = get_post_meta($order_id, sprintf('_%s', $field['key']), true)) {
      $this->billing_fields[$field['key']] = [
        'key' => $field['key'],
        'label' => $field['label'],
        'value' => $value
      ];
    } elseif (isset($this->billing_fields[$field['key']])) {
      unset($this->billing_fields[$field['key']]);
    }
    

    (and the same for the shipping and additional fields). If you point Quadlayers to this thread they should be able to help resolve this issue, unfortunately it’s not something we can change/fix on our end because this code is executed by WooCommerce Checkout Manager PRO.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Issue on generating pdf by group actions’ is closed to new replies.