Wordpress Woocommerce
Budget: $10 – $30 USD
Hello,
I need some help to figure a solution.
I am making a middle page between the product page and add to cart.
In that new custom page, I want to add the "add to cart page"
<?php do_action( 'woocommerce_before_add_to_cart_button' ); ?>
I figured the issue was from my custom function that you can read below:
//Adding a custom field into frontend
function cfwc_display_custom_field() {
global $product;
// Check for the custom field value
$product = wc_get_product( $post->ID );
$fna = $product->get_meta( 'arabic_name' );
if( $fna ) {
// Only display our field if we've got a value for the field title
printf(
'<div class="cfwc-custom-field-wrapper"><label for="cfwc-fna">%s</label><input type="text" id="cfwc-fna" name="cfwc-fna" value=""></div>',
esc_html( $fna )
);
}
$fns = $product->get_meta( 'second_language_name' );
if( $fns ) {
// Only display our field if we've got a value for the field title
printf(
'<div class="cfwc-custom-field-wrapper"><label for="cfwc-fns">%s</label><input type="text" id="cfwc-fns" name="cfwc-fns" value=""></div>',
esc_html( $fns )
);
}
}
add_action( 'woocommerce_before_add_to_cart_button', 'cfwc_display_custom_field' );
The problem is $product->id and it makes the page not render correctly because it's not knowing what $product is. I need help to make it work.
For professional WordPress developers, this will require 10 minutes only and are only required to give a textual solution through chat so 10 USD MAX BUDGET. Write "Read" to make sure you read what's needed.
I will provide full code through Pastebin if needed.
I need some help to figure a solution.
I am making a middle page between the product page and add to cart.
In that new custom page, I want to add the "add to cart page"
<?php do_action( 'woocommerce_before_add_to_cart_button' ); ?>
I figured the issue was from my custom function that you can read below:
//Adding a custom field into frontend
function cfwc_display_custom_field() {
global $product;
// Check for the custom field value
$product = wc_get_product( $post->ID );
$fna = $product->get_meta( 'arabic_name' );
if( $fna ) {
// Only display our field if we've got a value for the field title
printf(
'<div class="cfwc-custom-field-wrapper"><label for="cfwc-fna">%s</label><input type="text" id="cfwc-fna" name="cfwc-fna" value=""></div>',
esc_html( $fna )
);
}
$fns = $product->get_meta( 'second_language_name' );
if( $fns ) {
// Only display our field if we've got a value for the field title
printf(
'<div class="cfwc-custom-field-wrapper"><label for="cfwc-fns">%s</label><input type="text" id="cfwc-fns" name="cfwc-fns" value=""></div>',
esc_html( $fns )
);
}
}
add_action( 'woocommerce_before_add_to_cart_button', 'cfwc_display_custom_field' );
The problem is $product->id and it makes the page not render correctly because it's not knowing what $product is. I need help to make it work.
For professional WordPress developers, this will require 10 minutes only and are only required to give a textual solution through chat so 10 USD MAX BUDGET. Write "Read" to make sure you read what's needed.
I will provide full code through Pastebin if needed.