Your request was seen 2 hours after your posting. I have asked the developer to respond to this inquiry. His response may be delayed. Thanks.
I thank you, I only need that to finish the project if you have to charge me something for this no problem contact me
Thank you, I await your response
Even if you paid us, there would still be a waiting period. It takes up to four weeks for simple changes. I am at the mercy of the developers and they are exceedingly slow. Sorry!
Hello @fmunozn,
Sorry for the delay in responding due to different timezone, I always tried best to answer as soon as possible.
As you know that the “Product Code for WooCommerce” is an add-on the Product Code can not be fetched via a woocommerce inbuilt product functions. Also, there is no function like get_product_code() which you are using. So obviously it will show an error.
Product Code data are saved as a meta key and value to the “postmeta” table of WordPress.
To get it displayed for your custom code you can use the following snippet.
function product_code_shortcode() {
global $product;
if( $product ) {
$product_id = $product->get_id();
// Check if product is variable product type
if( $product->is_type( 'variable' ) ){
//get all variation list
$variations = $product->get_available_variations();
if( $variations ) {
foreach( $variations as $variable_product ) {
$value = get_post_meta( $variable_product['variation_id'], "_product_code_variant", true );
$code = !$value ? __( 'N/A', 'product-code-for-woocommerce' ) : $value;
echo 'CODE: ' . $code . '<br/>';
}
}
} else {
$value = get_post_meta( $product_id, "_product_code", true );
$code = !$value ? __( 'N/A', 'product-code-for-woocommerce' ) : $value;
echo 'CODE: ' . $code;
}
}
}
add_shortcode('codenew', 'product_code_shortcode');
Hope my answer helps you. Let me know further.
Thanks
Abdullah
Hello @westerndeal @artiosmedia
it worked perfect I appreciate your help.
You could add it to the frequently asked questions, I think it is super useful, I congratulate you for the development, it helped me a lot in my project, thank you.
from Chile.
@fmunozn Please kindly leave a review for the developers quick and accurate response and no fees charged: https://wordpress.org/support/plugin/product-code-for-woocommerce/reviews/
I married a Chilean lady from Temuco in 2010 🙂 Wonderful people.