Hello 🙂
I try to use “checkbox” :
Title field : Climatisation avant
Name field : climatisation_avant
Type field : checkbox
Choice : Climatisation avant
In Code Snippets plugin, I added :
add_action( 'woocommerce_single_product_summary', 'importexport17_custom_climatisation_avant_field', 11 );
function importexport17_custom_climatisation_avant_field() { ?>
<?php if(get_field('climatisation_avant')) { ?>
<div class="cg-climatisation_avant"><?php the_field('climatisation_avant'); ?></div>
<?php }
}
In my page, front backend) I can see :
But in the page (front end) I see that :
Many thanks by advance if you can help me.
Hi,
I am looking for a way to create following.
The current situation:
I have an option page with a repeater with a text subfield.
Client enters text values in the repeater subfield which generate WooCommerce product tabs with the correct labels.
These values are then dynamically filling a select field in the post/product edit screen, in this case a button group. All working fine.
The desired situation:
The content of the WooCommerce tabs need to be post/product specific.
So, when selecting a button in the post/product edit screen, a wysiwyg field needs to appear where the client can enter it’s specific content for the product. A bonus would be a true/false button to toggle the WooCommerce tab on/off.
I know how to create a field or field group in a php file but based on a selection from a select field remains a mystery.
Thanks you in advanced!
Hello, i using ACF with group for example “Color” and inside it i have Label named Color and choices like “Red”, “Blue”, “Purple” based on (checkbox) for woocommerce products, i would like to sort the choices Alphabetically on backend and frontend, cant figure out how can i do that ? is it possible anyway ?
Hello!
I am trying to create an FAQ repeater to my archive-product.php (category pages) in WooCommerce + Storefront but unfortunately, it’s not working. It skips right over the “if” statement and just says “Come back later”. Am I missing something here since I’ve never come across an issue like this and didn’t find a solution for this from anywhere else?
Full code of the template:
<?php
/**
* The Template for displaying product archives, including the main shop page which is a post type archive
*
* This template can be overridden by copying it to yourtheme/woocommerce/archive-product.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you
* (the theme developer) will need to copy the new files to your theme to
* maintain compatibility. We try to do this as little as possible, but it does
* happen. When this occurs the version of the template file will be bumped and
* the readme will list any important changes.
*
* @see https://docs.woocommerce.com/document/template-structure/
* @package WooCommerce\Templates
* @version 3.4.0
*/
defined( 'ABSPATH' ) || exit;
get_header( 'shop' );
/**
* Hook: woocommerce_before_main_content.
*
* @hooked woocommerce_output_content_wrapper - 10 (outputs opening divs for the content)
* @hooked woocommerce_breadcrumb - 20
* @hooked WC_Structured_Data::generate_website_data() - 30
*/
do_action( 'woocommerce_before_main_content' );
?>
<header class="woocommerce-products-header">
<?php if ( apply_filters( 'woocommerce_show_page_title', true ) ) : ?>
<h1 class="woocommerce-products-header__title page-title"><?php woocommerce_page_title(); ?></h1>
<?php endif; ?>
<?php
/**
* Hook: woocommerce_archive_description.
*
* @hooked woocommerce_taxonomy_archive_description - 10
* @hooked woocommerce_product_archive_description - 10
*/
do_action( 'woocommerce_archive_description' );
?>
</header>
<?php
if ( woocommerce_product_loop() ) {
/**
* Hook: woocommerce_before_shop_loop.
*
* @hooked woocommerce_output_all_notices - 10
* @hooked woocommerce_result_count - 20
* @hooked woocommerce_catalog_ordering - 30
*/
do_action( 'woocommerce_before_shop_loop' );
woocommerce_product_loop_start();
if ( wc_get_loop_prop( 'total' ) ) {
while ( have_posts() ) {
the_post();
/**
* Hook: woocommerce_shop_loop.
*/
do_action( 'woocommerce_shop_loop' );
wc_get_template_part( 'content', 'product' );
}
}
woocommerce_product_loop_end();
/**
* Hook: woocommerce_after_shop_loop.
*
* @hooked woocommerce_pagination - 10
*/
do_action( 'woocommerce_after_shop_loop' );
} else {
/**
* Hook: woocommerce_no_products_found.
*
* @hooked wc_no_products_found - 10
*/
do_action( 'woocommerce_no_products_found' );
}
?>
<div class="container FAQ">
<div class="row">
<div class="col-md-12">
<?php if( have_rows('faq') ):
$i = 1; // Set the increment variable
?>
<div id="accordion">
<?
// loop through the rows of data for the tab header
while ( have_rows('faq') ) : the_row();
?>
<div class="card" itemscope itemprop="mainEntity" itemtype="https://schema.org/Question">
<div class="card-header" id="heading-<?php echo $i;?>">
<button class="btn btn-link collapsed" data-toggle="collapse" data-target="#collapse-<?php echo $i;?>" aria-expanded="true" aria-controls="collapse-<?php echo $i;?>">
<span class="accordion-title" itemprop="name"><?php the_sub_field('question'); ?></span>
</button>
</div>
<div id="collapse-<?php echo $i;?>" class="collapse" aria-labelledby="heading-<?php echo $i;?>" data-parent="#accordion">
<div class="card-body" itemscope itemprop="acceptedAnswer" itemtype="https://schema.org/Answer">
<span itemprop="text"><?php the_sub_field('answer'); ?></span>
</div>
</div>
</div>
<?php $i++; // Increment the increment variable
endwhile; //End the loop
?>
</div>
<?php
else :
// no rows found
echo 'Come back later';
endif;?>
</div>
</div>
</div>
<?php
/**
* Hook: woocommerce_after_main_content.
*
* @hooked woocommerce_output_content_wrapper_end - 10 (outputs closing divs for the content)
*/
do_action( 'woocommerce_after_main_content' );
/**
* Hook: woocommerce_sidebar.
*
* @hooked woocommerce_get_sidebar - 10
*/
do_action( 'woocommerce_sidebar' );
get_footer( 'shop' );
Hello all. I’m currently developing a frontend editable area for users and it’s going great using acf_form().
Now, I’m about to move on to editable events using the WooCommerce Event Manager which has its own custom fields. My question is it possible to get these to load using the acf_form() function. Having no success at the moment.
Thanks,
James
I am trying to add columns to my admin area from a custom post type.
The code below successfully adds two columns, the ‘Sale or Charter’ column returns the correct value, but the ‘featured’ returns the value ‘array’ rather than ‘yes’ or blank. The first is a radio button the second is a checkbox.
What am I doing wrong?
Secondly, is it possible to actually add the checkbox in the admin column? In the same way you have a star for featured products in WooCommerce.
Alternatively adding the option to the quick edit area.
Any help greatly appreciated.
/*
* Add columns to Yacht Listings
*/
function add_acf_columns ( $columns ) {
return array_merge ( $columns, array (
'featured' => __ ( 'Featured' ),
'sale_or_charter' => __ ( 'Listing Type' )
) );
}
add_filter ( 'manage_yachts_posts_columns', 'add_acf_columns' );
/*
* Add columns to yacht post list
*/
function yachts_custom_column ( $column, $post_id ) {
switch ( $column ) {
case 'featured':
echo get_post_meta ( $post_id, 'featured', true );
break;
case 'sale_or_charter':
echo get_post_meta ( $post_id, 'sale_or_charter', true );
break;
}
}
add_action ( 'manage_yachts_posts_custom_column', 'yachts_custom_column', 10, 2 );
Hi …
Am using the following code to try and output a link to the Woocommerce category but I cannot get the term_object to output anything – any pointers where I cam going wrong?
I have a sub field which is selecting a single category from the standard ‘product_cat’ in WooC.
<?php
if (have_rows('feature_categories')) {
while (have_rows('feature_categories')) {
the_row();
$term = get_sub_field('link_category');
$taxonomy = 'product_cat';
$term_link = get_term_link($term, $taxonomy);
$image = get_sub_field('category_image');
?>
<div class="col-xs-12 col-md-4"><a href="<?php echo $term_link; ?>">
<?php echo wp_get_attachment_image( $image, 'webblock' ); ?>
<h4><?php the_sub_field('category_title'); ?></h4></a>
</div>
<?php
}
}
?>
Thanks in advance for any help!
Hi there,
let’s say I create a page with a repeater that displays a series of ‘cards’ with maybe four bits of information. Its a kind of index. On another page, in this case a WooCommerce product page I would like to add three of the cards from the repeater on the index page.
I would go to the product page and hopefully there would be a way to add three of the cards by selecting them in some way? The idea would be that the information is centralised.
Can I do this?
Chris
Hello all, I want to create an e-commerce website for my electronics store. one of my friends suggests me to create through woocommerce. I do not know so much about how I create an online store through WordPress and woo commerce, the main reason to build the online store is the online market is growing day by day and after the corona, it expands rapidly. Please help me how I create an online store?
Hello,
Any idea how can the custom fields still appear when the plugin is active in the single order page of Woocommerce?
I have products what have variations and I want show related products based which variation is selected and show product ACF fields on that.
My product view and under that is related products:
<?php
global $product;
if (!defined('ABSPATH')){
exit;
}
$test = get_post_meta( $post->ID, '_black_products_ids', true );
//$product = new WC_Product(get_the_ID());
//$related_products = $product->get_upsells();
$related_products_count = count($test);
get_header('shop');
?>
<?php while ( have_posts() ) :
the_post(); ?>
<article class="product">
<section class="mt-5 pt-5">
<div class="container-fluid single-box p-4">
<?php do_action( 'woocommerce_before_single_product' ); ?>
<div class="row">
<div class="col-md-4 mb-md-0 mb-3">
<?php wc_get_template( 'single-product/product-image.php' ); ?>
</div>
<div class="col-md-8">
<div class="single-inner d-flex flex-column h-100 p-md-4 p-0">
<div class="row">
<div class="col-md-6">
<h1><?php the_title(); ?></h1>
</div>
<div class="col-md-6">
<h2 class="mt-md-0 mt-3"><?php _e('About product', 'rv'); ?></h2>
</div>
</div>
<div class="row pt-3">
<div class="col-md-6">
<?php if( have_rows('product_info') ): ?>
<div class="single product-info">
<?php while( have_rows('product_info') ) : the_row(); ?>
<div class="row">
<div class="col-md-3">
<p class="mb-0 heading"><?php the_sub_field('info_heading'); ?></p>
</div>
<div class="col-md-9">
<p class="mb-0 value"><?php the_sub_field('info_value'); ?></p>
</div>
</div>
<?php endwhile; ?>
</div>
<?php endif; ?>
<div class="cart-box pt-4">
<?php do_action( 'woocommerce_single_product_summary' ); ?>
</div>
</div>
<div class="col-md-5">
<?php the_content(); ?>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<?php if($related_products_count > 0): ?>
<section class="beige pt-5 pb-3">
<div class="container-fluid px-0">
<div class="row">
<div class="col-md-12">
<h2 class="mb-4 all-title"><?php _e('Related products', 'rv'); ?></h2>
<article>
<div class="row">
<?php foreach($test as $related_product):
$post_object = get_post($related_product);
setup_postdata($GLOBALS['post'] =& $post_object);
wc_get_template_part('single-product-card');
endforeach; ?>
</div>
</article>
</div>
</div>
</div>
</section>
<?php endif; ?>
</article>
<?php endwhile;?>
<?php get_footer('shop');
My related product card view where I should get parent product data:
<?php
// Get product thumbnail
$product_thumbnail = (get_the_post_thumbnail_url()) ? get_the_post_thumbnail_url() : wc_placeholder_img_src();
$product = wc_get_product( get_the_ID() ); ?>
<div class="col-lg-3 col-md-6 mb-md-0 mb-3 <?php if(is_front_page()) { echo 'pr-0 pl-md-3 pl-0'; }?>">
<article class="product-card h-100 p-3">
<a class="h-100 d-flex flex-column" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
<img src="<?php echo $product_thumbnail; ?>" class="card-img img-fluid position-relative" alt="<?php the_title(); ?>">
<div class="card-price py-1 px-3">
<p class="mb-0 <?php echo esc_attr( apply_filters( 'woocommerce_product_price_class', 'price' ) ); ?>"><?php echo $product->get_price_html(); ?></p>
</div>
<div class="card-header-details pt-3">
<div class="row">
<div class="col-md-12 mb-3">
<h3 class="card-title mb-0"><?php the_title(); ?></h3>
</div>
<div class="col-md-12">
<?php if( have_rows('product_info') ): ?>
<div class="product-info">
<?php while( have_rows('product_info') ) : the_row(); ?>
<div class="row">
<div class="col-md-3">
<p class="mb-0 heading"><?php the_sub_field('info_heading'); ?></p>
</div>
<div class="col-md-9">
<p class="mb-0 value"><?php the_sub_field('info_value'); ?></p>
</div>
</div>
<?php endwhile; ?>
</div>
<?php endif; ?>
</div>
</div>
</div>
</a>
</article>
</div>
Hi,
I have added a an extra description under the Product category (product_cat) like a WYSIWYG input field.
So far soo good. I named it “extra description”
Ive installed a snippet plugin to add the php code.
Now i want to display this under the product category page in position “woocommerce_after_main_content”
So how will this code look like? Tried several php-snippets but it wont work , pleeease help.
My two cent, would be fantastic if this plugin would be able to add shortcodes so we just could put in easier. Thanks!
Seems like it should be easy enough to remove/add the dropdown created by ACF from above the Woo product block into the “general” tab. I can’t find the function to remove/add it. I’ve seem some write-ups about moving/adding a text field but that doesn’t seem to apply to other options. Any direction would be appreciated!
Hi!
Currently I am adding a banner to the shop page for Woocommerce. I do that with the use of action hooks:
//add banner to shop
add_action( 'woocommerce_before_main_content', 'cp_add_banner', 3 );
function cp_add_banner(){
get_template_part('template-parts/banner');
}
Yet for some reason, the group doesn’t work on the shop page. It simply isn’t loading when using sub fields in a group.
The banner.php:
<section class="main-banner container-full">
<img class="logo" src="<?php bloginfo('template_url'); ?>/assets/images/logo.svg" alt="logo">
<?php if( have_rows('main_banner') ):
while( have_rows('main_banner') ): the_row(); ?>
<img src="<?php the_sub_field('image'); ?>">
<?php endwhile;
endif; ?>
</section>
When I remove the if statement of the group, it load the banner.php. But when I start using the group again, it stops working completely.
Is there a way to solve this, or what is my oversight?.
Thank you in advance.
Hi,
I use ACF in order to implement the product description on WooCommerce.
I still have problems displaying the custom field on my single product page.
The custom field name is “Compatibility”.
I added the following code in – Flatsome Child: functions.php – but it doesn’t work.
add_action('woocommerce_before_add_to_cart_form', 'display_product_fields' );
function display_product_fields() {
$fields = Compatibility ();
if( $fields ): ?>
<ul>
<?php foreach( $fields as $field ): ?>
<li><?php echo $field['label']; ?>: <?php echo $field['value']; ?></li>
<?php endforeach; ?>
</ul>
<?php endif;
}?>
I am using ACF to append some fields to the Woocommerce registration form using a plugin. In my staging site this is working fine. However in the live site the fields are prefilled with the last submission. The data is also not saving.
Creating a new page and adding the form to it fixed the issue temporarily. However the after a day the issue is there again.
Hello everyone,
I am trying to sort the products in my product page by an ACF field. I want all the products with a value of this field displayed first and after that all other products.
My fields name is “season” and if the value is “55” the post should be displayed in front of all other posts.
I tried to change the query of “woocommerce_product_query” but I don’t know why it doesn’t work.
Here is the code I tried:
$query->set( 'meta_query',
array(
'relation' => 'AND',
'collection' => array(
'key' => 'season',
'value' => '55',
'compare' => '='
),
'normal' => array(
'key' => 'season',
'value' => '55',
'compare' => '<'
)
),
);
$query->set('orderby', array(
'collection' => 'DESC',
'normal' => 'DESC'
));
I hope anyone can help me with my problem.
Thanks in advance.
Hi there
Brand new here and have a pre purchase question.
My e-commerce site currrently uses Woocommerce Extra product options and custom code for my product wizard. I’m migrating the website to Oxygen and I’m looking at alternative ways to make the user experience better. Instead of the wizard before placing an order I wondered if it’s possible to create a dashboard using ACF so that once a customer places an order depending what product they ordered they a presented with a dashboard to add the info I need. Image uploads, select boxes, date picker and so on. The reason for doing this way is to make it quicker for the customer to order and reduce abandoned carts. Any thoughts would be greatly appreciated.
And example of the current wizard can be seen on the link below
https://minifyme.co.uk/shop/design-your-own/custom-bobbleheads-single/
Thanks in advance
John
Hi,
I would like to display text next to my attributes on my product page. I found that I need to edit this template:
<?php
/**
* Product attributes
*
* Used by list_attributes() in the products class.
*
* This template can be overridden by copying it to yourtheme/woocommerce/single-product/product-attributes.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you
* (the theme developer) will need to copy the new files to your theme to
* maintain compatibility. We try to do this as little as possible, but it does
* happen. When this occurs the version of the template file will be bumped and
* the readme will list any important changes.
*
* @see https://docs.woocommerce.com/document/template-structure/
* @package WooCommerce\Templates
* @version 3.6.0
*/
defined( 'ABSPATH' ) || exit;
if ( ! $product_attributes ) {
return;
}
?>
<table class="woocommerce-product-attributes shop_attributes">
<?php foreach ( $product_attributes as $product_attribute_key => $product_attribute ) : ?>
<tr class="woocommerce-product-attributes-item woocommerce-product-attributes-item--<?php echo esc_attr( $product_attribute_key ); ?>">
<th class="woocommerce-product-attributes-item__label"><?php echo wp_kses_post( $product_attribute['label'] . "<a>" . the_field('beschrijving_tooltip,') . " Tooltip</a>"); ?></th>
<td class="woocommerce-product-attributes-item__value"><?php echo wp_kses_post( $product_attribute['value']); ?></td>
</tr>
<?php endforeach; ?>
</table>
I’m want to display the value I put in text field but I dont know what ID i should put after the_field(‘beschrijving_tooltip’, $ID?)
The acf field: https://prnt.sc/103w6gi
I would like to display the same custom fields for all posts (Woocommerce Orders)
So if I edit the field in one Order and save it and then open another Order, the field has updated there as well.
Essentially create a custom field with global values that are globally shared / the same values across all the posts.
The intention is the following, in our physical store we have parcel lock-boxes and we sent and send the code from them to the customer on email, however we would like to be able to edit the safe code directly from the order page.
Some light in the right direction would be great, I have been trying to achieve this however unsuccessfully,
thank you in advance for the attention and advice
Hi all,
I’ve implemented Javascript on this page : https://www.fortunesoftit.com/woocommerce-development-company/
and my page speed has slowed down.
Any suggestions how can I improve it.
Thanks
Hey! Seems that with Woocommerce this plugin interacts a bit differently. I made some ACF fields on my Shop page, but when trying to retrieve them in archive-product.php file, nothing shows up. How could I go around this problem?
Hi All, I’m creating a WooCommerce site as a replacement site for one written in the Laravel framework that has some unusual requirements. The site sells sheet music, textbooks, musical instruments and accessories and for this reason I’ve had to create a large number of custom fields – 22 so far, there may be more. The biggest problem however is just the sheer amount of products. I’ve so far got 180,000 of them and I’ve seen a database with over 560,000. This gives me two problems, the first is searches but Lucene Solr has solved that for me. The second is getting the data in to WooCommerce and the ACF fields and later updating those fields. A short test on a dev box indicates uploading that amount of data will take 5-6 days so what’s the quickest way there is of doing that? Obviously the quickest route would be direct from an XML using SQL but the complexity of the product data and ACF structures make that more awkward than I’d like.
Any suggestions here?
How can I set the value of an ACF, dependent upon the woocommerce product type?
I was looking to add custom fields to my shop front page and category pages, which displays all products. I believe these are classed as archive pages.
The aim is to have the ability to add a banner and three or four columns below the banner that are all controlled via custom fields.
I tried creating these fields and assigning the fields to the page name and additionally to the post type ‘Product’. It seems to be working on the individual product pages, though not on the Shop front and category pages.
Would it be best to create these fields and assign them to the ‘Options Page’ or is there another work around for this?
In summary:
custom field for banner and four custom filed columns below banner
Would like to work on both Archive product pages and Category pages, so that promo banners and offers can be displayed.
Thanks in advance!
Kev