Support

Account

Home Forums Search Search Results for 'woocommerce'

Search Results for 'woocommerce'

topic

  • Helping

    How to pull WooCommerce Fields like SKU?

    G’day All,

    I’ve tried to find information on the forum, within the plugin/support blog. Whilst I’m not a complete n00b – I do feel like I’m missing the basics here.

    I’ve got basic ACF Fields being shown on the product page so I know ACF is working as intended.
    ie. [acf field="product_specifications_material"]

    I need to create a table of product specifications on my Woocommerce website, some products technically have multiple skus, of which variants change the code presented.

    Example: Widget A / Widget B / Widget C = WA, WB, WC.
    At the bare basics, I was hoping to pull the current post/product SKU using ACF, then modifying using the “repeater” function. As so much data is already within the product meta field, I was hoping to re-use rather than need to update two variables.

    Thus far, I’ve been unable to find any function that exists within ACF to simply pull existing WooCommerce Data. Am I missing something here?

  • Helping

    Make ACF field searchable in admin backend

    We are running a WooCommerce shop and have added an ACF field to all products and want to make this field searchable in the admin backend.

    I found a forum-thread from 2018
    https://support.advancedcustomfields.com/forums/topic/add-acf-fields-to-admin-search/
    where the last entry refers to a plugin that is no longer available unfortunately.

    Does anybody here have a recommendation or solution to set up admin search for ACF fields?

  • Solving

    Custom review fields display

    Hello

    I created custom fields in Review section of woocommerce single product, that are showing, however when the review is posted the fields are not showing, how can I output them to show them in the review also?

  • Solving

    How to use this code in acf ?

    <?php
    $slider_off = get_field('slider_off', 'option');
    ?>
           <?php if ($slider_off) { ?>
    
                <div class="special-discounts col-xxxl-3 col-xl-4 col-lg-4">
                    <div class="swiper mySwiper">
                        <div class="swiper-wrapper">
                            <?php foreach ($slider_off as $list) {
                                $item = $list['slider_off_product'];
                                $pro_id = $item->ID;
                                $myproduct = new WC_Product($pro_id);
                                $product = wc_get_product($pro_id);
                                $account_game = $product->get_attribute('platform');
                                $product_type = $product->get_type();
                                $stock = $myproduct->get_stock_quantity();
                                $pro_old_price = $myproduct->get_regular_price();
                                $pro_new_price = $myproduct->get_sale_price();
                                $pro_title = $product->get_name();
                                $pro_image = get_the_post_thumbnail($pro_id, array(192, 192));
                                $pro_link = get_permalink($pro_id);
                                $product_logo_pic = get_field('product_logo_pic', $item);
                                $differenceInSeconds = 0;
                                if ($product_type == 'variable') {
                                    $variations = $product->get_available_variations();
                                    $variations_id = wp_list_pluck($variations, 'variation_id');
    
                                    if (!empty(get_defualt_attr($product))) {
                                        ...
                                }
                                if ($product->is_type('variable')) {
                                    ...
                                    }
                                    // Array row output
                                } else {
                                    ...
                                }
                                ?>
    
                               <!-- code -->
    
                            <?php } ?>
    
                        </div>
                        
                    </div>
    
                </div>
            <?php } ?>

    HI, I can make the slider_off true or false , but I can’t make a connection between the slider_off_product and the product post in woocommerce ! How should I act to display the product post in this code? In fact, what is the meaning of the $item = $list[‘slider_off_product’]; in the code? And how should it be implemented in acf plugin ?
    sorry for my bad english.

  • Unread

    Repeater not returning posts in english language

    I have an acf that takes the woocommerce products (which are not translatable, so there is only the italian version), this is the structure:


    acf_add_local_field_group(array(
    'key' => 'group_65017e7235881',
    'title' => 'Home CPO',
    'fields' => array(
    array(
    'key' => 'field_65017e798dde7',
    'label' => 'Orologi in evidenza',
    'name' => 'orologi_in_evidenza',
    'type' => 'repeater',
    'instructions' => '',
    'required' => 0,
    'conditional_logic' => 0,
    'wrapper' => array(
    'width' => '',
    'class' => '',
    'id' => '',
    ),
    'collapsed' => '',
    'min' => 0,
    'max' => 0,
    'layout' => 'table',
    'button_label' => '',
    'sub_fields' => array(
    array(
    'key' => 'field_65017e8a8dde8',
    'label' => 'Orologio',
    'name' => 'orologio',
    'type' => 'post_object',
    'instructions' => '',
    'required' => 0,
    'conditional_logic' => 0,
    'wrapper' => array(
    'width' => '',
    'class' => '',
    'id' => '',
    ),
    'post_type' => array(
    0 => 'product',
    ),
    'taxonomy' => array(
    0 => 'product_cat:rolex-cpo',
    ),
    'allow_null' => 0,
    'multiple' => 0,
    'return_format' => 'object',
    'ui' => 1,
    ),
    ),
    ),
    ),
    'location' => array(
    array(
    array(
    'param' => 'page_template',
    'operator' => '==',
    'value' => 'index-cpo.php',
    ),
    ),
    ),
    'menu_order' => 0,
    'position' => 'normal',
    'style' => 'default',
    'label_placement' => 'top',
    'instruction_placement' => 'label',
    'hide_on_screen' => '',
    'active' => 1,
    'description' => '',
    ));

    If I use the italian language, then the repeater will display all the products available. Otherwise, if I switch to english language the repeater doesn’t show anything.
    This issue is kinda weird ’cause in the english version I can see all the products from the woocommerce dashboard but not from the repeater.

    I’m trying to change the lang parameter that is sent from the ajax request of acf, so I did this:


    function customize_acf_query($args, $field, $post_type)
    {
    $args['lang'] = 'it';
    return $args;
    }
    add_filter('acf/fields/post_object/query', 'customize_acf_query', 10, 3);

    but again, the acf doesn’t display any products. Could someone help me?

    Thanks in advance!

  • Solved

    Should I use conditional logic to display fields?

    A very basic question that I can’t seem to find an answer to and really hope someone can advise. Sorry, it’s so simple – I can (just about) adapt php code but am not a coder.

    When I want to display the value of a WYSIWYG field, should I use the simple

    <?php the_field(‘field_name’); ?>

    Or should I put it in conditional logic in case the field value is null:

    <?php if( get_post_meta($post->ID, “field-name”, true) ): ?>
    <?php echo get_post_meta($post->ID, “field-name”, $single = true);?>
    <?php endif; ?>

    I don’t want to do anything else with these particular fields, just display them.

    I’m asking both with regards to page load speed (eg number of database queries) and also to try to prevent some of the 504 crashes my site has been having recently when I am editing pages. (The crashes began when my husband rebuilt our AWS server in order to upgrade php for the upcoming Woocommerce php change requirement; we found that changing from php 7.4 to 8.1 helped matters but has not fixed issues and so I am now looking at trying to revise/check all of my coding.)

  • Solving

    Add ACF fields as Custom Order Line Item Meta

    Hello,

    How can I add a custom field data as Item meta when the order is saved? Is there anyone who has experience with that?

    https://drive.google.com/file/d/1Y_Q8kb1j3BZhLpbuH2OpqQyxL0bvF_MG/view?usp=sharing

    I tried the code below but it didn’t help:

    
    add_action( 'woocommerce_checkout_create_order_line_item', 'display_acf_on_orders_and_emails', 10, 4 );
    function display_acf_on_orders_and_emails( $item, $cart_item_key, $values, $order ) {
        $name = get_field('name', $order_id);
    
        if ( isset($values['name']) ) {
            $item->add_meta_data( 'Name', $values['name'] );
        }
    
    }
    

    Thank you in advance!

  • Helping

    Displaying all ACF field labels and values from a specified field-group on WooC

    I’m trying to display the contents of a specific ACF field group in a tab on a WooCommerce single product page. Unfortunately I’m not getting any data displayed using the code below, although I do if I list each field manually. Not an elegant solution and not future-proof with potential changes to the number of fields in the group. Is it also possible to specify the field group by name rather than ID for portability to other sites? Also no field should be displayed if there is no value.

    
        /*==============================================================
    * Create More Details tab 
    ================================================================*/
    if (class_exists('acf') && class_exists('WooCommerce')) {
    	add_filter('woocommerce_product_tabs', function($tabs1) {
    		global $post, $product;  // Access to the current product or post
    		
    		$custom_tab_title = '';
     
    			$tabs1['rpl-' . sanitize_title($custom_tab_title)] = [
    				'title' => 'More Details',
    				'callback' => 'rpl_custom_woocommerce_tabs',
    				'priority' => 10
    			];
    
    		return $tabs1;
    	});
     
    	function rpl_custom_woocommerce_tabs($key) {
    		global $post;
     
    		?><h2><?php echo $tab1['title']; ?></h2><?php
    		$specs_fields = get_specs_fields();
                  
    		foreach ( $specs_fields as $name => $field ):
    			$value = $field['value'];
    	?>     
    		<strong><?php echo $field['label']; ?>:</strong>
          <?php echo $value; ?>      
    	 <?php endforeach; 
    }
    	function get_specs_fields() {
    	global $post;
    	
    	$specs_group_id = 17; // Post ID of the specs field group.
    	$specs_fields = array();
    	
    	$fields = acf_get_fields( $specs_group_id );
    	
    	foreach ( $fields as $field ) {
    		$field_value = get_field( $field['name'] );
    		
    		if ( $field_value  && !empty( $field_value )) {
    			echo $field['value']; 
    			$specs_fields[$field['name']] = $field;
    			$specs_fields[$field['name']]['value'] = $field_value;
    		}
    	  }
    	}
    	return $specs_fields;
    }
    
  • Helping

    Disable custom field on pagination pages (elementor)

    Hi,

    I’m stuck and can’t deal with the duplication of content.

    I have an extra field created in ACF that displays on the product archive template above the products. I don’t want this field to display on pagination subpages, ie other than the first product category subpage. Product category archive created in theme builder. The theme used is underscores.

    The site is elementor pro + woocommerce + ACF.

    Can anyone direct me to the correct custom code that will solve my problem?

  • Solving

    Conditional Display of ACF Single Product Page

    Hello,

    I am creating a page to sell to different categories of products. My issue is that not all the fields pertain to all categories. So what I would like to do is display only the fields that are relevant to the product. I am currently using this code to display fields in my product page (Works great, except is shows for all categories):

    
    /* Custom fields on Proudct Page */
    
    add_action( 'woocommerce_single_product_summary', 'sbnai_display_acf_field_1', 30 );
    function sbnai_display_acf_field_1() {
    	echo '<b>Per Round Cost:</b> ' . get_field('per_round_cost') . '<br />';
    	echo '<b>UPC:</b> ' . get_field('upc') . '<br />';
    	echo '<b>Caliber:</b> ' . get_field('caliber') . '<br />';
    	echo '<b>Bullet Weight:</b> ' . get_field('bullet_weight') . '<br />';
    	echo '<b>Bullet Type:</b> ' . get_field('bullet_type') . '<br />';
    	echo '<b>Case Type:</b> ' . get_field('case_type') . '<br />';
    	echo '<b>Combined Reviews:</b> ' . get_field('combine_reviews') . '<br />';
    }
    
    add_action( 'woocommerce_single_product_summary', 'sbnai_display_acf_field_2', 31 );
      
    function sbnai_display_acf_field_2() {
    	echo '<b>Width:</b> ' . get_field('width') . '<br />';
    	echo '<b>Height:</b> ' . get_field('height') . '<br />';
    	echo '<b>Depth:</b> ' . get_field('depth');
    }
    

    I’ve separated the fields based on relevance, group 1 if for Category “Ammo” the second group is for category “guns”.

    Any help will be greatly appreciated.

  • Solving

    acf field hooking up with woocommerce hook

    im trying to display acf field in woocommerce product-data -> general tab
    woocomerce hook

    
    add_action('woocommerce_product_options_general_product_data', 'add_custom_file_upload');
    function add_custom_file_upload() {
    if( function_exists('acf_add_local_field_group') ):
    
    acf_add_local_field_group(array (
        'key' => 'group_12uyy',
        'title' => 'My Group 123',
        'fields' => array (
            array (
                'key' => 'field_1',
                'label' => 'Sub Title light',
                'name' => 'sub_title_light',
                'type' => 'file',
                'prefix' => '',
                'instructions' => '',
                'required' => 0,
                'conditional_logic' => 0,
                'wrapper' => array (
                    'width' => '',
                    'class' => '',
                    'id' => '',
                ),
                'default_value' => '',
                'placeholder' => '',
                'prepend' => '',
                'append' => '',
                'maxlength' => '',
                'readonly' => 0,
                'disabled' => 0,
            )
        ),
        'location' => array (
            array (
                array (
                    'param' => 'post_type',
                    'operator' => '==',
                    'value' => 'product',
                ),
            ),
        ),
        'menu_order' => 0,
        'position' => 'normal',
        'style' => 'default',
        'label_placement' => 'top',
        'instruction_placement' => 'label',
        'hide_on_screen' => '',
    ));
    
    endif;
    }
    

    but when im trying to hookup acf field with woocommerce_product_options_general_product_data, its not displaying

  • Solving

    acf field hooking up with woocommerce hooks

    im trying to display acf field in woocommerce product data > genreal tab
    woocommerce product data

    add_action('woocommerce_product_options_general_product_data', 'add_custom_file_upload');
    function add_custom_file_upload() {
    if( function_exists('acf_add_local_field_group') ):
    
    acf_add_local_field_group(array (
        'key' => 'group_12uyy',
        'title' => 'My Group 123',
        'fields' => array (
            array (
                'key' => 'field_1',
                'label' => 'Sub Title light',
                'name' => 'sub_title_light',
                'type' => 'file',
                'prefix' => '',
                'instructions' => '',
                'required' => 0,
                'conditional_logic' => 0,
                'wrapper' => array (
                    'width' => '',
                    'class' => '',
                    'id' => '',
                ),
                'default_value' => '',
                'placeholder' => '',
                'prepend' => '',
                'append' => '',
                'maxlength' => '',
                'readonly' => 0,
                'disabled' => 0,
            )
        ),
        'location' => array (
            array (
                array (
                    'param' => 'post_type',
                    'operator' => '==',
                    'value' => 'product',
                ),
            ),
        ),
        'menu_order' => 0,
        'position' => 'normal',
        'style' => 'default',
        'label_placement' => 'top',
        'instruction_placement' => 'label',
        'hide_on_screen' => '',
    ));
    
    endif;
    }

    im trying to hook acf field-> file type with woocommerce_product_options_general_product_data but im unable to display acf field type in woocommerce hook.

    acf field is not displayed in product data -> general tab

  • Helping

    Show ACF Field in WooCommerce Add New Product for Specific Category

    Hi there,

    I need help in showing the ACF fields that I’ve created in WooCommerce Add New Product Page for a specific category only. That specific category would have some sub-category and I would like to include those as well. I can’t choose Post Type as Product because I have different fields customized for different product category.

    Currently, I could only make it to show in the Edit Product Page. If I choose the location rules as Post Taxonomy for a certain product type or product cat, then it’ll only show those ACF fields in the Edit Product Page as that particular post is published, and so it has its own taxonomy queried. However, before the post is published (add new product page), it would not show since it doesn’t have any taxonomy query yet.

    Is there anything that I can set to make this work or any advice on this? Would appreciate very much for the help given. Thanks

  • Solved

    Display Dropdown list selected value ?

    Hi there.
    I am using ACF to create a dropdown list field for the wordpress admin to select a value among 2 for each woocommerce product.
    That part is ok, but I want to show only the selected value on the front end of each product page.
    In functions.php, I tried something like
    $color = get_field('vente_location');
    but it failed.
    Thanks for any help!

  • Solving

    Shortcode without postid

    Hi, I’m working in Learndash/Woocommerce/Wordpress.

    I run 20 different courses for tax preparers. There’s info that the IRS requires me to put on the completion certificate that LearnDash doesn’t have a place for, so I got ACF. I’d like to create one master certificate. LearnDash can put the student name on, great, and the date, also great, and I think the course title, but that’s being a bit wonky.

    But I need the IRS number and the number of credits. So I’m trying to use ACF for that. I can enter those numbers at the exam level, no problem.

    The problem comes when the shortcode (example: <div style=”width:290px;margin:auto;text-align:center;”>[acf field="irs_course_number_exam post_id="1120"]</div>) wants that post id. If I want the one certificate to draw from the exam they just took, then I can’t specify the post id.

    Can I set up the shortcode without a post_id?

  • Unread

    Copy Woo data to ACF Fields

    I’ve created a field group that displays on the backend of my Woocommerce edit product page.

    Within the group, there are two fields 1. max_offer 2. win – both of which are Number Field Types.

    I want these fields to match the following Woocommerce data fields.

    max_offer = Regular Price
    win = Stock Quantity

    As an item is sold, the win field should be updated automatically to match the updated Stock Quantity.

    Is there a way for me to achieve the above?

    Thanks

  • Helping

    Include taxonomy slug in CPT URL

    Hi:

    I create “productos” CPT using ACF and a custom taxonomy “categoria-producto” asociated to “productos” CPT

    I would like the item URL was:

    mipage.com/tienda/%categoria-producto%/sample-product

    As Woocommerce product (mipage.com/tienda/product-category/sample-product/)

    How can i do that??

    Thxs

    Regards

  • Solved

    How can I exclude extra relationship posts from Woocommerce archive loop?

    I’m working on a Woocommerce site that is integrated with a Store system. This system does not support regular Woocommerce variations so we used an ACF relationship field to create a custom variation selection on the frontend product page.

    The client has requested that if products are variations only 1 of those should be displayed in the archive/category/search loop, so we need to exclude these extra products from the loop, but keep 1 of them.

    What is the best way for me to do this?

    My initial thought is looping through all products, create an array of product_ids that has values in the relationship field and 1 for the relationship values. array_diff those to only be left with extra varaitions. Then adding that array to post__not_in in pre_get_posts action.

    Am I on the right track, I’m worried this might be too slow and wondering if there’s another speedy/optimal way to do this?

  • Unread

    Customer Tag

    Hi there,

    When a customer buys a product, I want to attach a tag to it.

    I have created a selection field in ACF with the following pre-filled values:
    – Kamerplanten
    – Gazon
    – Moestuin
    – Siertuin

    I will fill in these values for each product. When a customer purchases a product, I want this value to be visible in the order.

    I am using the same field for both the products and the orders, so it’s a single field.

    When a customer places an order, I want the values from the product to be copied to the order. Therefore, it is possible for an order to have more than one filled value.

    I have been working with ChatGPT, but I can’t get the code to work. You can find the chat with ChatGPT here: Link(I apologize that it’s in Dutch).

    The latest code that ChatGPT shared with me is:

    
    // Voeg deze code toe aan je functions.php bestand in het thema van je WordPress-website
    
    // Voeg het verborgen aangepaste veld "Klanttag" toe aan het bestelformulier op de checkout-pagina
    function add_custom_field_to_checkout($checkout) {
        $product_id = 0;
        $product = null;
    
        // Haal het product-ID op van de eerst toegevoegde productregel in de bestelling
        if (WC()->cart && WC()->cart->get_cart()) {
            foreach (WC()->cart->get_cart() as $cart_item_key => $cart_item) {
                $product_id = $cart_item['product_id'];
                break;
            }
        }
    
        if ($product_id) {
            $product = wc_get_product($product_id);
        }
    
        if ($product) {
            $klanttag_field = get_field_object('klanttag', $product_id);
            $klanttag_options = $klanttag_field['choices'];
    
            if (!empty($klanttag_options)) {
                echo '<input type="hidden" class="input-hidden" name="klanttag" id="klanttag" value="">';
            }
        }
    }
    add_action('woocommerce_after_order_notes', 'add_custom_field_to_checkout');
    
    // Sla de waarde van het geselecteerde aangepaste veld "Klanttag" op in de bestelling
    function save_custom_field_to_order($order) {
        if (isset($_POST['klanttag'])) {
            $klanttag = sanitize_text_field($_POST['klanttag']);
            $order->update_meta_data('Klanttag', $klanttag);
        }
    }
    add_action('woocommerce_checkout_create_order', 'save_custom_field_to_order');
    
    // Kopieer de waarde van het selectievakje "Klanttag" van het product naar de bestelling
    function copy_custom_field_to_order($item, $cart_item_key) {
        $product_id = $item['product_id'];
        $klanttag = get_field('klanttag', $product_id);
    
        if (!empty($klanttag)) {
            $item->add_meta_data('Klanttag', $klanttag, true);
        }
    }
    add_action('woocommerce_checkout_create_order_line_item', 'copy_custom_field_to_order', 10, 2);
    

    Please place this complete code in the functions.php file of your active theme in WordPress. After adding the code, the “Customer Tag” field will be hidden on the checkout page, the selected value will be saved in the “Customer Tag” field of the order, and it will also be copied to the order line item of each product in the order.

    Can anyone help me get this code working?

  • Solving

    need extra tabs in wooCommerce product page

    Hello all……
    my requirement is to have extra tabs in wooCommerce product page(few tabs beside description)
    The content to these tabs has to be populated from CSV or Excelsheet…..

    I’ve installed ACF plugin ,created fields with text area….
    where do i edit my backend….please help

  • Helping

    Date front end display format

    I’m struggling to convert an ACF date picker field to be displayed in the correct format on the front end.

    I’m using this snippet to display the 2 product custom fields on the order confirmation and the associated email.

    add_action( 'woocommerce_order_item_meta_start', 'order_item_meta_start', 10, 4 );
    function order_item_meta_start($item_id, $item, $order, $plain_text) {
    	$the_order_id = $order->get_id();
    	$order_items = $order->get_items();
    	$custom_field_variable1 = get_post_meta( $item->get_product_id(), 'competition_reference', true ); // Change custom_field_name to the name of your custom product meta field
    	$custom_field_variable2 = get_post_meta( $item->get_product_id(), 'competition_draw_date', true ); // Change custom_field_name to the name of your custom product meta field
    	echo '<p>Competition Reference: ' . $custom_field_variable1 . '<br>Competition Draw Date: ' . $custom_field_variable2 . '</p>';
    }

    It works in the fact it displayed the ACF data, but it displays the date as YYYYMMDD rather than my ACF return format of dd/mm/YYYY

    Product
    LEGO® Star Wars™ Darth Vader Helmet (75304)
    Competition Reference: LegoDV_001
    Competition Draw Date: 20230630

    How can I return the date correctly?

  • Unread

    ACF wooCommerce UPC codes

    I need to display UPC codes in our wooCommerce store. I need to add UPC codes for simple products and also for variable products. Not sure how to even start or where to start. Hoping someone here can start me off.

    Any help would be appreciated.
    Thanks in advance
    Vince

  • Unread

    Applying category values to products automatically

    I’m not sure, if ACF is able to create a scenario I’m planning – that’s the cause of the question:

    I will have a field group, each field have an own value set (field 1: a,b,c; field 2: 123,456,789; field 3: eur,gbp,usd).

    I want to apply certain combination of field values in this group (field 1: a; field 2: 123; field 3: eur;) to certain Woocommerce category.

    How to apply same fields and their values to all products in this category? All means currently existing and added in the future.

    Example: all Woocommerce categories have field group “watch properties” with fields “diameter” and “thickness”. Category “Swatch Skin” has fields values like “diameter: 30mm”, “thickness: 2mm”. Category view displays both fields and values and the values are searchable with any ACF search plugin.

    Now I add to this category some affiliate products – fields and values “diameter: 30mm” and “thickness: 2mm” will be automatically applied to them. Searching in products is not mandatory.

    What do you think about getting this scenario done?

  • Solving

    Compare Products

    I would like to create on my Website with Avada Theme installed a Compare Products if possible without using Woocommerce. It need only to view differents tech specs about our product.
    I link to you a website like example with a section compare products that wi would like to replicate.

    https://www.huddly.com/conference-cameras/

    It is possible with your plugin?

    Let me know
    Thanks

  • Helping

    removing existing fields from registration form

    I have a new registration form for WooCommerce which contains an email address field in the correct place I want it to appear in the new form.

    However WooCommerce seems to add its own email address field below by own new form.

    Is there a way to disable the original field and simply use the new one that I created in the ACF form?

Viewing 25 results - 26 through 50 (of 1,322 total)