WordPress All-Import to ATUM Stock Management
When importing and creating/updating products in WooCommerce the fields used in and by ATUM Stock Management doesn't get updated.
On the stockmanagementlabs forum one user posted a suggestion to be added to functions.php:
add_action('pmxi_saved_post', 'post_saved', 10, 1);
function post_saved($id) {
// get custom field
$purchase_price = get_post_meta($id, '_atum_purchase_price', true);
// Insert the field into the database
if(isset($purchase_price)){
$wpdb-update(
"{$wpdb-prefix}atum_product_data",
array(
'column1' = 'purchase_price',
'column2' = $purchase_price
),
array(
'product_id' = $id
),
array(
'%s',
'%d'
),
array( '%d' )
);
}
// Clean up unneeded custom field (OPTIONAL)
delete_post_meta( $id, '_atum_purchase_price' )
}
This was later somewhat updated and revised by a developer of ATUM:
add_action('pmxi_saved_post', 'after_wpai_post_saved');
function after_wpai_post_saved($id) {
// get custom field
$purchase_price = get_post_meta($id, '_atum_purchase_price', true);
// Insert the field into the database
if( $purchase_price !== FALSE ){
$wpdb-update(
"{$wpdb-prefix}atum_product_data",
array(
'purchase_price' = $purchase_price,
),
array(
'product_id' = $id
),
array('%f'),
array('%d')
);
}
// Clean up unneeded custom field (OPTIONAL)
delete_post_meta( $id, '_atum_purchase_price' )
}
This code however renders the white screen of death.
What I basically want to be able to do is import supplier ($supplier), supplier's SKU ($supplier_sku) and purchase price ($purchase_price) to ATUM while using WPAI to create/import products.
Topic import bulk-import Wordpress
Category Web