InvoiceFox / CebelcaBIZ-WooCommerce

WooCommerce (Wordpress) plugin for integration with InvoiceFox.
4 stars 12 forks source link

Fixed an undefined variable - fixing PDF invoice attachments #4

Closed lukaske closed 4 years ago

lukaske commented 4 years ago

For PDF invoices to be downloaded wp-content/uploads/invoices must exist. I had to create it manually. I suggest said folder creation is implemented during plugin init.

P1robot commented 4 years ago

Automated benchmark results (pass #0): passed

concurrency: 32
requests per second: 6160
concurrency: 128
requests per second: 7641
concurrency: 512
requests per second: 4685
concurrency: 1024
requests per second: 4006
tiln7 commented 4 years ago

Hi, does enclosing PDFs to Woocommerce email now work? I still have problems making it work. Woocommerce-order email is sent to the customer, however, generated cebelca email is not enclosed in the email.

Thanks, Tilen tilen@anfio.eu

lukaske commented 4 years ago

Yes, it's working for me now. There are 2 things required:

1) Make sure wp-content/uploads/invoices folder exists. I had to create it manually and add an appropriate .htaccess file to restrict URL access to invoices.

2) Add a filter in your theme's functions.php that attaches invoices to emails. Example:

function attach_file_woocommerce_email($attachments, $id, $object)
{           
    if($id == 'customer_completed_order')
    {   

    try {
        $str = "invoicefox_attached_pdf";
        $updated_order = wc_get_order( $object->get_id());
        $upload = $updated_order->get_meta($str, True);
        error_log("Emailing invoice: ");
        error_log($upload); 
        $attachments[] = $upload;  

     }

    catch (Exception $e) {
        error_log($e->getMessage());
     }
    }

    return $attachments;
}
add_filter('woocommerce_email_attachments', 'attach_file_woocommerce_email', 10, 3);
tiln7 commented 4 years ago

Hi,

thanks for the reply. I have already created a new folder + added a filter in functions.php. Invoices are generated in cebelca but not enclosed in the emails (cant really figure why). Is there a newer version of plugin I am not aware of? or sth else?

These are my settings:

Kind regards, Tilen

On 26 Feb 2020, at 19:50, Luka Skeledzija notifications@github.com wrote:

Yes, it's working for me now. There are 2 things required:

Make sure wp-content/uploads/invoices folder exists. I had to create it manually and add a .htaccess to restrict URL access to invoices.

Add a filter in your theme's functions.php that attaches invoices to emails. Example:

function attach_file_woocommerce_email($attachments, $id, $object) {
if($id == 'customer_completed_order') {

try {
    $str = "invoicefox_attached_pdf";
    $updated_order = wc_get_order( $object->get_id());
    $upload = $updated_order->get_meta($str, True);
    error_log("Emailing invoice: ");
    error_log($upload); 
    $attachments[] = $upload;  

 }

catch (Exception $e) {
    error_log($e->getMessage());
 }
}

return $attachments;

} add_filter('woocommerce_email_attachments', 'attach_file_woocommerce_email', 10, 3);

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/InvoiceFox/InvoiceFox-integration-WooCommerce/pull/4?email_source=notifications&email_token=AJMM7RKBK6JG3S7K22O7NQDRE22X7A5CNFSM4J7LPGL2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOENBNMFA#issuecomment-591582740, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJMM7RLFIMSSKGC2HB2RZMDRE22X7ANCNFSM4J7LPGLQ.

lukaske commented 4 years ago

I think your settings are missing.

Are you using my fork of this plugin?

There were a few lines of code missing in the original source code. I added those (part of this merge request). Also make sure your Woocommerce orders include a 'invoicefox_attached_pdf' parameter. It should be automatically added to each order after submission to cebelica.biz. You should be able to see this if you check the details of the order in Woocommerce dashboard.

tiln7 commented 4 years ago

Thanks a lot! It works!

Owe you a beer :)

Lep pozdrav, Tilen

On 26 Feb 2020, at 20:11, Luka Skeledzija notifications@github.com wrote:

I think your settings are missing.

Are you using my fork of this plugin https://github.com/lukaske/InvoiceFox-integration-WooCommerce?

There were a few lines of code missing in the original source code. I added those. Also make sure your Woocommerce orders include a 'invoicefox_attached_pdf' parameter. It should be automatically added to each order after submission to cebelica.biz. You should be able to see this if you check the details of the order in the Woocommerce dashboard.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/InvoiceFox/InvoiceFox-integration-WooCommerce/pull/4?email_source=notifications&email_token=AJMM7RMVXLRI6P2Z4J5D62DRE25F5A5CNFSM4J7LPGL2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOENBPVHY#issuecomment-591592095, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJMM7RKOOVEPYT7PK6DQ4KTRE25F5ANCNFSM4J7LPGLQ.

lukaske commented 4 years ago

Ni za kej :)