Plugin Support
Mike M. a11n
(@mikedmoore)
Automattic Happiness Engineer
Hi there,
Order items, such as products, are stored in the wp_woocommerce_order_items
table in the database while order metadata is stored in the wp_woocommerce_order_itemmeta
table. I’m not sure you’ll be able to update the order items without using WooCommerce functions or direct database inserts into those tables.
@mikedmoore Thanks for reply. Well I turn off loading Woocommerce.php in wp-settings.php file because I just want to include Woocommerce manually in my code when I need it. Also, I don’t want to include and use all files of Woocommerce. I just want to create objects of Order and Product classes, but I don’t know which files of Woocommerce should I include. I use following code before creating the objects of Order and Product classes, but it doesn’t solve my problem and I receive the error :”Call to a member function get_product() on null”.
require_once( plugin_dir_path(__DIR__) . '/woocommerce/woocommerce.php' );
WC_Post_Types::register_taxonomies();
WC_Post_Types::register_post_types();
WC_Post_Types::register_post_status();
do_action( 'woocommerce_after_register_post_type' );
do_action( 'woocommerce_init' );
global $woocommerce;
Please guide me.
@mostafadeveloper If you were running into issues while using WooCommerce’s built in classes and functions we may be able to assist you, however since you are not we cannot. Without completely duplicating the code, you will not be able to create an order and assign everything correctly. It is recommended that you load the WooCommerce code and use the existing functions and methods.