Hello,
I search for displaying in the cart and in the order a few custom field ; how i can do this ?
thank you.
Dear Thierry,
I assume we are talking about WooCommerce cart page, you can edit the theme file for rendering the cart page, use Types function types_render_field() to render the custom fields created with Types plugin:
https://toolset.com/documentation/customizing-sites-using-php/functions/
You can also try with WordPress function do_shortcode() to render shortcodes:
https://codex.wordpress.org/Function_Reference/do_shortcode
Thanks luo, I rewrite the cart.php file.
but i don't succeed to display à custom fields on this. Please, can you explain ?
It needs custom PHP codes, and I have already provided the document links:
https://toolset.com/documentation/customizing-sites-using-php/functions/
If you still need assistance for it, please provide a test site with the same problem, fill below private detail box with login details and ftp access, also point out the problem page URL and where I can edit your PHP codes, which custom field do you want to display. I need a live website to test and debug.
I have tried the credentials you provided above, but get this error:
This site can’t be reached
shop.thierryra*****.fr took too long to respond.
Please check it, thanks
Hi, i think that's now it's ok.
It is difficult to connect to your test site, I get same error message:
This site can’t be reached
shop.thierryra*****.fr took too long to respond.
Could you provide a copy of your website by follow our document:
https://toolset.com/faq/provide-supporters-copy-site/
And fill below private detail box with a downloadable URL for the duplicator package
Thanks for the details, I can download the files, here are what I found
1) Your custom theme file cart.php does not work, the cart in the front-end, display empty in the content area. So I create a new cart.php, by below steps:
2) Copy the original template file cart.php from Woocommerce plugin
\wp-content\plugins\woocommerce\templates\cart\cart.php
To your custom theme folder "generatepress_child":
\wp-content\themes\generatepress_child\woocommerce\cart\cart.php
Now the cart in the front-end works fine
3) Edit above theme file:
\wp-content\themes\generatepress_child\woocommerce\cart\cart.php
line 94, add below line:
socho: <?php echo types_render_field('socho', array('post_id'=>$product_id));?>
It will be able to display the custom field "socho" value, just after the product name.
As you can see in above PHP codes, you can add parameter "post_id" to specific the post(product) ID.
Thanks Luo, it's work.
Last thing please, for display the same field in the invoice, how i can do ?
It is a new question, please create a new thread for it, and describe detail steps for the question:
display the same field in the invoice
Where and how can I see the invoice?
Thanks
yes the same field in the customer's invoice.
I checked again in the duplicator package you provided, there is an order page in:
hidden link
But there isn't any "customer's invoice".
To avoid any more misunderstand, please describe detail steps for the question:
display the same field in the invoice
Where and how can I see the invoice?
Can you point out the problem page URL? thanks
sorry for the late.
in fact i want displaying the custom field (socho) in the customer's invoice withe this plugin :
hidden link
it's possible ?
I have already provide an example for you in above post for how to display the custom fields using PHP function:
https://toolset.com/forums/topic/displaying-custom-field-in-the-cart-and-order/#post-588195
For your new question:
in fact i want displaying the custom field (socho) in the customer's invoice withe this plugin
It is a new question, which is different from the original question of this thread:
https://toolset.com/forums/topic/displaying-custom-field-in-the-cart-and-order/
I am not familiar with the plugin "WooCommerce PDF Invoices & Packing Slips" you mentioned above, but it should be possible within custom PHP codes, if you still need assistance for it, please create a new thread for it:
1) describe detail steps to duplicate same problem
2) Where and how can I see the invoice?
3) Where and how do you want to display the custom fields?
Thanks Luo, i'll open a new thread.