This question already has an answer here:
Display ACF field/image below the product title in WooCommerce archive pages
(1 answer)
Closed last year.
For the website that i'am building i try to get the dimensions of the product directly under the product title on the overview.
Here i want the dimensions
in ACF i made a field called 'productkaart_afmetingen' were i can fill in the dimensions data at every product. But i can't manage to load it in under the product title.
i tried adding
the_field('productkaart_afmetingen');
to the content-product.php in my child theme folder but this made the dimensions appear above the title and i can't manage to get is under the title
Code goes in functions.php
add_action( 'woocommerce_product_thumbnails', 'display_acf_field_under_images', 30 );
function display_acf_field_under_images() {
echo '<b>ACF Field:</b> ' . get_field('productkaart_afmetingen');
// Note: 'productkaart_afmetingen' is the slug of the ACF
}
Related
This question already has answers here:
Add extra details Woocommerce order edit pages in admin
(2 answers)
Closed 11 months ago.
I am saving some extra products to order meta during checkout and I want to show those products into woocommerce admin order details section and it need to look like regular products.
I am looking for any woocommerce hooks available to acheive this task without customization woocommerce core file.
I'm not sure I totally understand but is this what you mean?:
add_action( 'woocommerce_after_order_itemmeta', 'custom_info_after_order_itemmeta', 20, 3 );
function custom_info_after_order_itemmeta( $item_id, $item, $product ) {
//echo stuff here
}
I've created a custom field using ACF and I want to show it in my WooCommerce single product page. How can I do that?
You need to find out the hook that represents the place where the ACF field should be displayed, e.g. by using the WooCommerce Visual Hook Guide for the single product page.
example
add_action( 'woocommerce_after_single_product_summary', 'view_acf_field_for_single_product', 10 );
function view_acf_field_for_single_product(){
if (function_exists('the_field')){
the_field('field_name');
}
}
This is adapted from https://support.advancedcustomfields.com/forums/topic/acf-with-woocommerce/.
I would like to modify the products sorting on the shop page to product categories filter where the user can select the browse the products of categories from there.
I am a rookie in programming. I checked the WooCommerce directory to find the .php file I should work on. I got some clue it is in archive-product.php but I don't see the code which display the sorting dropdown.
Can anyone give me some clue to achieve this ? Or is there any workaround ? Thanks.
I added this in functions.php :
// remove default sorting dropdown
remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30 );
// now add the new dropdown
add_action( 'woocommerce_before_shop_loop', 'add_product_category_dropdown' );
function add_product_category_dropdown(){
print '<span class="woocommerce-ordering">'; // So it takes the same position as the default dropdown
the_widget( 'WC_Widget_Product_Categories', 'dropdown=1' );
print '</span>';
}
The reason you wouldn't see the code is that majority of what is generated by Woocommerce is handled by actions and hooks. In easier terms this means Woocommerce creates functions that spits out content and assigns them to different areas of the website.(For more information on Woocommerce actions and hooks, read here - https://docs.woothemes.com/document/introduction-to-hooks-actions-and-filters/ )
I'd recommend using the plugin below. It does exactly what you seem to be asking for and you can avoid having to play in parts you might not be comfortable with yet.
https://wordpress.org/plugins/yith-woocommerce-ajax-navigation/
Most awesome thing is that it's not one of those plugins that force you to get premium to actually get the desired effect.
I just found the solution few days ago. I use the function of WooCommerce product categories widget on the shop page.
This line of code will output the dropdown of product categories:
<?php the_widget( 'WC_Widget_Product_Categories', 'dropdown=1' ); ?>
Is there a way my category archive display both full posts and excerpts?
What I want is the first two or three latest posts display as full content posts, and all the others as excerpts with just title and a read more button. These are displayed on one page. I am currently using a category archive, on the twentyfifteen theme.
I know I can set a page to either display full or just excerpts, but not a combination. Is this possible?
Thanks!
You can get these in your wordpress loop on page or post.
<?php
$content = get_content($post->ID); //full content of post
$excerpt = substr($content,0,150); //you can limit charaacter like 150
?>
I need to move the titles of the products, while I am browsing the category page, over their thumbnails
Details:
I have created a shop page where I only display the categories.
Every category contains 1 to 10 products.
Once I click a category, I land on a page where I see all of the products in that category.
I would like to see the titles of those products appearing over their thumbnails.
Thank you
A few more details relating to your parituclar setup are needed to give a proper answer. However, I'm going to assume you have everything at default. This is what you would need to add to the end of functions.php in your active theme folder:
remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10 );
add_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10 );
For reference, check https://github.com/woothemes/woocommerce/blob/master/templates/content-product.php and https://github.com/woothemes/woocommerce/blob/master/includes/wc-template-hooks.php
If this does not work, check:
that you use the latest version of woocommerce. Actually a few versions back should work the same, but not too far back.
that your woocommerce templates are not overwritten. Check your theme folder for a file called content-product.php or in a subfolder woocommerce/content-product.php. If that has been altered, you need to adjust accordingly, perhaps by making changes right there.
that your theme does not already mess around with product display hooks. If it does, find out what's different.
Please note that this changes behavior for all woocommerce loops, such as any shortcodes you might be using and the "related products" section in single product view, if that is enabled. To affect only categories, the changes should be wrapped in a condition check ( is_product_category() ).
If you put code into a plugin, you must wait for WooCommerce loading:
add_action('plugins_loaded', function()
{
// move product's title before product thumbnail instead of next to that
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_title', 5);
add_action('woocommerce_before_single_product_summary', 'woocommerce_template_single_title');
}
Added this CSS for the product title and it worked fine for me. I used media query of course.
position: absolute;
top: 0px;