我正在使用 ALD – AliExpress 和 WooCommerce 的 Dropshipping 和 Fulfillment 插件。有没有办法在管理产品列表新列中显示产品的所有可用运输国家/地区(我的意思是包含每个产品中可运输的所有国家/地区的列表的列)。
我尝试了一个名为 //Product Visibility by Country for WooCommerce// 的插件,显示国家/地区列,但此插件的问题是您应该手动添加每个产品的可用国家/地区。
我想问是否有一个功能可以显示每个产品已经链接的国家
就我而言,我使用插件从不同来源导入数据,并且产品会自动随可用的运输国家/地区一起提供。所以现在要知道每种产品适用于哪些国家并不容易,我只能通过访问结帐页面并针对每个国家进行手动检查来了解。
希望有一个功能可以在产品列表中以一栏显示它们。
运输国家数据是使用PLugin从速卖通导入的, 为了实现目标(在一列中显示所有可用的国家/地区),我们必须分析每个单独产品页面中的所有国家/地区(因为 AliExpress 对于每个国家/地区都有单独的页面),并筛选哪些国家/地区可用,哪些国家/地区不可用,并生成数据。 这将很复杂并需要更多资源。 但是,您可以使用下面的代码显示选择导入产品的主要发货国家/地区,此代码仅显示一个国家/地区,而不是所有可用的发货国家/地区。
// Add a custom column to the product list in the WordPress admin
function add_shipping_country_column( $columns ) {
$columns['shipping_country'] = 'Shipping Country';
return $columns;
}
add_filter( 'manage_product_posts_columns', 'add_shipping_country_column' );
// Populate the custom column with shipping country data from the "_vi_wad_shipping_info" custom field
function populate_shipping_country_column( $column, $post_id ) {
if ( $column == 'shipping_country' ) {
$ali_import_id = VI_WOOCOMMERCE_ALIDROPSHIP_DATA::product_get_id_by_woo_id( $post_id );
// Get the post type to check if it's a product or another post type
// Get the shipping information from the "_vi_wad_shipping_info" custom field
$shipping_info = ALD_Product_Table::get_post_meta( $ali_import_id, '_vi_wad_shipping_info', true );
// Check if the shipping_info field exists and contains data
if ( ! empty( $shipping_info ) ) {
// Unserialize the data
$shipping_info_data = maybe_unserialize( $shipping_info );
// Check if the 'country' key exists
if ( isset( $shipping_info_data['country'] ) ) {
$shipping_country = $shipping_info_data['country'];
// Display the shipping country
echo esc_html( $shipping_country );
} else {
echo 'N/A'; // Display N/A if the 'country' key is not found
}
} else {
echo 'N/A'; // Display N/A if the shipping_info field is empty
}
}
}
add_action( 'manage_product_posts_custom_column', 'populate_shipping_country_column', 10, 2 );