• Resolved lolitsjohnnyboy

    (@lolitsjohnnyboy)


    I think I’ve found an issue within the following file:

    wp-content/plugins/woocommerce-germanized/includes/export/class-wc-gzd-product-export.php

    In this file you are adding custom columns to the exporter but within the admin_init action. At my plugin I’m accessing the WooCommerce columns this way but within a running Cron job. The problem is: I only get the columns from WooCommerce and not yours because of the fact, that Cron jobs are not calling admin_init. Within the exporter on the WooCommerce page it works because this time the admin_init hook gets called.

    Any chance you can fix this in future releases?

Viewing 11 replies - 1 through 11 (of 11 total)
  • Thread Starter lolitsjohnnyboy

    (@lolitsjohnnyboy)

    My current workaround is to call the init function above my code but I think you can just register the export columns a bit earlier directly within a constructor. I see no need for a admin_init hook here…

    
    $gzd_product_csv_exporter = new WC_GZD_Product_Export();
    $gzd_product_csv_exporter->init();
    Plugin Author vendidero

    (@vendidero)

    Hi there,

    thanks for reporting!

    I’ve just improved the timing here: https://github.com/vendidero/woocommerce-germanized/blob/master/includes/export/class-wc-gzd-product-export.php

    Could you test that?

    Cheers

    Thread Starter lolitsjohnnyboy

    (@lolitsjohnnyboy)

    Hi,

    seems to be working now! Can you ship it within the next update?

    Cheers

    Plugin Author vendidero

    (@vendidero)

    Hi there,

    yes, the improvement will be included automatically.

    Cheers

    Thread Starter lolitsjohnnyboy

    (@lolitsjohnnyboy)

    Hey,

    sorry for getting back to this topic. I’ve found another issue! Now the timing works perfectly, but when I use the WooCommerce exporter class within a Cron job or backend function for example, your exporter class don’t gets loaded because it’s within an is_admin() check within the woocommerce-germanized.php file.

    Any chance you can move the exporter & importer include out of this check?

    include_once WC_GERMANIZED_ABSPATH . 'includes/export/class-wc-gzd-product-export.php';
    include_once WC_GERMANIZED_ABSPATH . 'includes/import/class-wc-gzd-product-import.php';

    is_admin() only resolves when you are actually on an admin page, which is not the fact at a backend function :/

    Otherwise, when I get the default exports columns for WooCommerce within my plugin (used by over 100 people for Collmex WaWi) during a Cron job for an automatic product import, your columns are missing and an error occurs during the import.

    Since my plugin supports Germanized, it would be very bad, if the columns are missing in this case.

    If there is no chance you can move the includes out of the check, please let me know. In this case, I need to do the include during the Cron job by myself. But I think, this case can happen more often and not only within my plugin.

    Plugin Author vendidero

    (@vendidero)

    Hi there,

    we are handling this the same way Woo handles the includes. The WC_Admin class (which registers and includes the exporters) is only included via admin requests (checked via is_admin). How do you actually solve that? Do you manually include the exporters?

    You might of course include the file(s) manually.

    Cheers

    Thread Starter lolitsjohnnyboy

    (@lolitsjohnnyboy)

    Hi,

    actually, the includes I’m talking about are included within this file:

    wp-content/plugins/woocommerce-germanized/woocommerce-germanized.php

    Since I’m including the importer from WooCommerce within my plugin, all extensions to the importer should be included automatically. If I do this within a backend function which gets not called via the admin dashboard, your includes are failing and I’m getting an WooCommerce importer without your export columns.

    Cheers

    Plugin Author vendidero

    (@vendidero)

    Since I’m including the importer from WooCommerce within my plugin, all extensions to the importer should be included automatically

    Unfortunately that is not possible as Woo does not offer hooks which could be used to auto-magically include files whenever an import/export class is instantiated.

    I’ve just updated the code to include those files during cron requests too:
    https://github.com/vendidero/woocommerce-germanized/commit/d4897574f46cff9353dab97fdab00b8b18158d7f

    Cheers

    Thread Starter lolitsjohnnyboy

    (@lolitsjohnnyboy)

    Awesome! This works. I’ve left a comment with a suggestion 🙂 Thanks a lot!

    Thread Starter lolitsjohnnyboy

    (@lolitsjohnnyboy)

    Hi!

    I just saw your 3.8.5 update. Sadly, this fix seems to be missing. Do you have any information about the release date? Currently, I’m not able to release my plugin because otherwise a lot of people will have issues regarding an important function.

    Cheers

    Plugin Author vendidero

    (@vendidero)

    I just saw your 3.8.5 update. Sadly, this fix seems to be missing. Do you have any information about the release date?

    It is scheduled for our 3.9 update which will (probably) be released this month.

    Cheers

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Problem with custom export columns’ is closed to new replies.