Support

Account

Home Forums Search Search Results for 'woocommerce'

Search Results for 'woocommerce'

reply

  • Thanks so much @vverner!

    I tested with:

    'taxonomy' => 'post_tag',

    and

    'taxonomy' => 'product_cat',

    But is not working. Remember this is a WooCommerce product category…

    Here are the other values:

    'hide_empty' 	=> true,
    'meta_key'	=> 'series_one_work',
    'meta_value'	=> '1'

    Any other suggestion?

  • Try this

    function vv_custom_cat_layout( $options ) {
    
    	$terms = get_terms( array(
    		'taxonomy' 		=> 'post_tag',
    		'hide_empty' 	=> true,
    		'meta_key'		=> 'name_of_field',
    		'meta_value'	=> 'the_desired_value'
    	) );
    
    	foreach($terms as $term){
    		$options['columns'] = 1;
    	}
    	
    	return $options;
    
    }
    
    add_filter( 'option_generate_woocommerce_settings','vv_custom_cat_layout' );

    *not tested

  • Thank you, I tried a few options but I am doing something wrong…
    I get the 1 column layout applied to every category

    /*Use 1 column layout for art series with one work*/
    add_filter( 'option_generate_woocommerce_settings','lh_custom_category_wc_columns' );
    function lh_custom_category_wc_columns( $options ) {
        if (  $query->query_vars['product_cat']  ) {
    
    		$query->set('meta_key', 'series_one_work');
    		$query->set('meta_value', '1');
    
    		}
    		
    	{
            $options['columns'] = 1;
        }
        
        return $options;
    }
  • Hi @3antz

    Yes this is possible with ACF, you can make use of the location rules to assign a field group to the orders post type.
    You will then need to find a suitable filter on this page https://docs.woocommerce.com/document/introduction-to-hooks-actions-and-filters/ to hook into inorder to display the fields on the orders page using the ACF functions the_field() and get_field().

  • Hey Rileym3,

    In my understanding, you created a product attribute named “variable” (WordPress Dashboard > Products > Attributes). Did you then:
    – create a “variable product” in WooCommerce, (“Product Data” section set to “variable product”),
    – selected your “variable” attribute in the “Attributes” tab
    – created a variation based on the selected attribute in the “Variations” tab?

    You would then find your “UPC code” variable below the “Description” field after you opened the variations you created for the product.

  • Hello, still not working.

    I’m in the main Shop page of woocommerce.

  • Hi @lightsage88

    It’s most likely that you are trying to load the field values before they are actually saved into the database.

    Kindly try changing the priority of the ‘woocommerce_email_after_order_table’ to above 10 to see if you are able to load the field.

    Hope to hear from you soon.

  • Hello,

    I have the same problem with ACF (Free). I need to add some fields to My Account Page, but I think that we need something like: Page -> is equal to -> Edit account.

    This feature, maybe is not supported by ACF and we need to get an Addon.

    Check this thread: https://support.advancedcustomfields.com/forums/topic/addon-for-woocommerce-my-account-page/

  • My last response seems to have disappeared. It turns out it was using “product_cat”, but that it was buried under hundreds of other choices (attributes, key words, etc). So it just wasn’t as obvious as it could have been.

    Would be nice if they also didn’t show the taxonomy options that don’t do anything, as it makes it look like you’d just choose the first options for categories. When i realized i had to scroll down through hundreds of options to find the WooCommerce version, it all worked fine and as expected.

    Thanks!

  • I should have followed up on this for others having an issue.

    Thanks @kpirnie for the suggestions.

    It turns out the solution was simple and straightforward, but that there was a lot of obfuscation going on to see it due to the drop down listing a few hundred other options for filtering. The list included attributes and keywords and everything else you can think of so i was trying to sort through a massive list of choices and didn’t initially realize there was a separate taxonomy selection for WooCommerce’s version of “product_cat”.

    The confusing aspect is that the taxonomy selection that comes up first just simply doesn’t work using the AND option. It would be nice if this was made more clear, or if selections that will do nothing are simply not displayed. I’m not sure how doable that would be, so it might not be that simple. So when i realized there was a separate taxonomy selection, but that is was buried hundreds of selections down, it worked just fine. Under the “product_cat” section, i was able to select the category i has chosen for the product.

    So it would be as follows:

    Post type = Product
    AND Taxonomy = [whichever one you have assigned]

    But ignore the initial listing of taxonomy or category, and find the one specifically for “product_cat” for WooCommerce.

    So it was as easy as it should have been, but hidden in plain site by a bunch of irrelevant selection options.

    Thanks!
    Glen Allan

  • Hi John!

    Thank you very much for your detailed suggestions. I’m thinking the same as you, as to create a Series CPT would be the more elegant and flexible solution.

    Tricky part with this project, is that we have a searchable catalog (probably going to use Facet WP for that), so exactly like a woocommerce site (series wont matter there), BUT on the artist page itself, client wants the works to be displayed in a slideshow AND divided by series, instead of linking to the actual product page.

    Anyways, i’ll fiddle with the Series CPT today and see what i’m coming up with.

    Thanks again for taking the time to answer me.

  • I’ve finally figured it out. This is what I used to be able to show my related posts on WooCommerce product pages:

    
    <?php 
    $vendorposts = get_field('related_posts');
    
    if( $vendorposts ): ?>
        <div class="latest_post_holder boxes three_columns two_rows">
        <ul>
        <?php foreach( $vendorposts as $post): // variable must be called $post (IMPORTANT) ?>
            <?php setup_postdata($post); ?>
            <li>
                        <?php if ( has_post_thumbnail( $rp->ID ) ) : ?>
    	  <?php echo get_the_post_thumbnail( $rp->ID, 'regular-posts' ); ?>
    <?php else : ?>
    	  <img src="<?php echo get_template_directory_uri(); ?>/img/no-image.png" alt="" />	
    	<?php endif; ?>
    	            <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
    
            </li>
        <?php endforeach; ?>
        </ul>
        </div>
        <?php wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly ?>
    <?php endif; ?>
  • I have a custom text field in which the data needs to have multiple spaces on the end. Its a special ID number for a 3rd party system we are integrating with WooCommerce products, and that systems IDs need to be packed up to 48 characters, if the actual ID characters do not add up to 48 then the rest is packed with spaces to fill it.

    It saves into the database OK with 48 characters and the ending with spaces, but when we load it on the product edit screen, all the end spaces are removed. Any spaces within any characters are kept, but the end ones are truncated.

    This means when saving the page, the spaces are removed in the database and then ID numbers wont match.

    How can we ensure ACF loads the exact data from the database and does not strip anything out not even spaces?

    Thanks

  • Imports are another story. Yes, repeaters can be used, but it requires special handling when importing from some other source. My personal preference is WP All Import Pro.

    If you’re talking about product attributes, if you’re using WooCommerce you might want to import into there instead of using ACF. But it all depends on what you’re going to do with the values and what the attributes represent. A useful links field seems like a good use of a repeater while it might not be the right choice for other types of data.

  • Hi Elliot,

    I have simmilar problem. After update WP to 5.1.1 and WooCommerce to 3.5.7 and ACF free to ACF pro, my custom fields had values. On the frontend WYSIWYG fields are cropped (one or few chars), after first save of the product, the content of the custom fields dissapears. New content inserted into CF’s doesn’t save…
    Could you please help me with this case?

  • I like to switch between product specs, when i change product variation.
    I should be nice if it is below the Description of Woocommerce.

    For example see Philips Lighting website.
    I want the specs of a LED Light switching when i change variation.
    Per lamp another specs below of the Description or a Tab.
    A table with with specs, copy and paste.

    Problem: When i make Product Type is Equal to Product Variation (WYSIWYG Editor). I don’t see the Editor at the Product Variation position.

  • Never mind, solved it.

    For anyone else with the same issue, here is how to do it.

    <?php
    	
    	if ( is_shop() ){
    		$page_id = get_option( 'woocommerce_shop_page_id' ); 
    	}
    	else {
    		$page_id = get_the_ID();
    	}
    
    if( have_rows('page_sliders', $page_id) ): ?>
    
    	<div id="carouselControls" class="carousel slide" data-ride="carousel">
    		<div class="carousel-inner">
    			<?php while( have_rows('page_sliders', $page_id) ): the_row(); 
    				// vars
    				$image = get_sub_field('slide_image', $page_id);
    				$link = get_sub_field('slide_image_url', $page_id);
    				$row = get_field('page_sliders', $page_id);
    				$rows = count($row);
    				?>
                    <div class="carousel-item <?php if (get_row_index() == 1) echo "active"; ?>">
    					<?php if( $link ): ?>
    						<a href="<?php echo $link['url']; ?>">
    					<?php endif; ?>
    						<img src="<?php echo esc_url($image['url']) ?>" alt="<?php echo $image['alt'] ?>" />
    					<?php if( $link ): ?>
    						</a>
    					<?php endif; ?>
    				</div>
    			<?php endwhile; ?>
    			<?php if ($rows > 1): ?>
                    <a class="carousel-control-prev" href="#carouselControls" role="button" data-slide="prev">
                        <span class="carousel-control-prev-icon" aria-hidden="true"></span>
                        <span class="sr-only">Previous</span>
                    </a>
                    <a class="carousel-control-next" href="#carouselControls" role="button" data-slide="next">
                        <span class="carousel-control-next-icon" aria-hidden="true"></span>
                        <span class="sr-only">Next</span>
                    </a>
                <?php endif; ?>
    		</div>
    	</div>
    
    <?php endif; ?>

    Kind regards
    Chris

  • @waterlemon Thank you for sharing your thoughts and final solution!
    I have exactly the same issue (I want to display an unique SEO description below my product feed on every woocommerce category site) but unfortunately your solution did not succeed so far.

    Could you – or @ma4ine – please specify a little more what you did:
    The changes were made in the taxonomy-product_cat.php or in archive-product.php?

    I tried both (incl. replacing the field name, of course) but nothing happend…
    First, I copied the original files and uploaded the changed files then to yourtheme/woocommerce/… to overwrite the original files (/plugins/woocommerce/templates/…). Maybe that is not the right way to do it?

    Would be very thankful to get more information on that. Unfortunately I have very few experience on programming etc. and trying to get that done for many hours now, puh… 😉
    Would be awesome, thanx!!

  • Hi Jhon,

    appreciate the reply! The code above is coming from woocommerce/content-single-product.php

    Basically there is an ACF field called featured_products that is displayed on the each product page while creating/editing a product. This would be so we can select what products we want to feature for the current product.

    With your help I have resolved the issue in the code previous developer had done.

    I amended the code and left out the following:

     <!--  php
                $meta_query  = WC()->query->get_meta_query();
                $tax_query   = WC()->query->get_tax_query();
                $tax_query[] = array(
                    'taxonomy' => 'product_visibility',
                    'field'    => 'name',
                    'terms'    => 'featured',
                    'operator' => 'IN',
                );
                
                $args = array(
                    'post_type'           => 'product',
                    'post_status'         => 'publish',
                    'orderby' => 'post_date',
                    'order' => 'DSC',
                    'posts_per_page'      => 4,
                    'meta_query'          => $meta_query,
                    'tax_query'           => $tax_query,
                );
                 -->

    Then edited the code below this to reflect

    <?php
                    $post_objects = get_field( 'featured_products' );
                       
                    
    			if( $post_objects ): ?> 
    

    while adjusting the code within the divs.

    THANK YOU SO MUCH! I would never have gotten this without your suggestion (and some heavy reading in the documentation!)

  • Hi i want to do something similar. I have a acf input field called “contado_en_local” and i want to replace the woocommerce regular price with it in the archive product page.
    The problem is that the acf field appears, but above the title and i want it below, and also it didn’t removed the woocommerce default regular price.
    Also i don’t how to style it. It is donde in the child-theme’s style.css?
    I made a custom plugin called WOOCOMMERCE ALE BIANCHI and insert this code in wp-content/plugins/woocommerce-ale-bianchi-audioarte.

    
     <?php 
     /* 
     Plugin Name: WOOCOMMERCE ALE BIANCHI
     Plugin URI: https://rampcrosario.com 
     Description: Funciones personalizadas Woocommerce para AudioArte 
     Version: 1.0.0 
     Author: ALE BIANCHI 
     Author URI: https://rampcrosario.com 
     License: GPL 2+ 
     License URI: https://rampcrosario.com 
     */
     
     
     //* Mostrar precio CONTADO creado con ACF en vez de DEBITO colocado en precio regular Woocommerce
    add_action( 'after_setup_theme', 'ale_custom_shop_woocommmerce' );
    
    function ale_custom_shop_woocommmerce () {
    
     remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );
     
     function ale_acf_precio() {
        if(get_field('contado_en_local'))
        
    	{
    		echo '<p>' . get_field('contado_en_local') . '</p>';
    	}
    	
    	}
    	add_filter( 'woocommerce_after_shop_loop_item_title', 'ale_acf_precio', 15 );
    
    }
     
  • Oups! “woocommerce_save_product_variation” action does not work properly.

    Replace with:

    add_action( 'woocommerce_save_product_variation', function( $variation_id, $loop_index ) {
    	if ( !isset( $_POST['acf_variation'][$variation_id] ) ) {
    		return;
    	}
    
    	if ( ! empty( $_POST['acf_variation'][$variation_id] ) && is_array( $fields = $_POST['acf_variation'][$variation_id] )  ) {
    		foreach ( $fields as $key => $val ) {
    			update_field( $key, $val, $variation_id );
    		}
    	}
    
    }, 10, 2 );
  • Found a solution for ACF fields requiring events to be attached.

    In your php code, add the following:

    function xxx_admin_head_post() {
    	global $post_type;
    	if ($post_type === 'product') {
    		wp_register_script( 'xxx-acf-variation', get_template_directory_uri() . '/js/acf-variation.js', array(
    			'jquery-core',
    			'jquery-ui-core'
    		), '1.1.0',
    			true ); // Custom scripts
    		
    		wp_enqueue_script( 'xxx-acf-variation' ); // Enqueue it!
    
    	}
    }
    
    /* actions fired when adding/editing posts or pages */
    /* admin_head-(hookname) */
    add_action( 'admin_head-post.php', 'xxx_admin_head_post' );
    add_action( 'admin_head-post-new.php',  'xxx_admin_head_post' );

    Create js/acf-variation.js with the following code:

    jQuery(document).ready(function($) {
        $( '#woocommerce-product-data' ).on( 'woocommerce_variations_loaded', function(){
            acf.doAction('ready');
        });
    });
  • This piece of code work for me, setting the location to “Taxonomy equals <<whatever attribute>>”. Note that, as variations are loaded dynamically, javascript events are not attached to fields. Thus, using the gallery or image does not work: click on buttons does nothing. Trying to find a fix…

    $GLOBALS['wc_loop_variation_id'] = null;
    
    function is_field_group_for_variation($field_group, $variation_data, $variation_post) {
    	return (preg_match( '/Variation/i', $field_group['title'] ) == true);
    }
    
    add_action( 'woocommerce_product_after_variable_attributes', function( $loop_index, $variation_data, $variation_post ) {
    	$GLOBALS['wc_loop_variation_id'] = $variation_post->ID;
    
    	foreach ( acf_get_field_groups() as $field_group ) {
    		if ( is_field_group_for_variation( $field_group, $variation_data, $variation_post ) ) {
    			acf_render_fields( $variation_post->ID, acf_get_fields( $field_group ) );
    		}
    	}
    
    	$GLOBALS['wc_loop_variation_id'] = null;
    }, 10, 3 );
    
    add_action( 'woocommerce_save_product_variation', function( $variation_id, $loop_index ) {
    	if ( !isset( $_POST['acf_variation'][$variation_id] ) ) {
    		return;
    	}
    
    	$_POST['acf'] = $_POST['acf_variation'][$variation_id];
    
    	acf()->input->save_post( $variation_id );
    }, 10, 2 );
    
    add_filter( 'acf/prepare_field', function ( $field ) {
    	if ( !$GLOBALS['wc_loop_variation_id'] ) {
    		return $field;
    	}
    
    	$field['name'] = preg_replace( '/^acf\[/', 'acf_variation[' . $GLOBALS['wc_loop_variation_id'] . '][', $field['name'] );
    
    	return $field;
    }, 10, 1);
Viewing 25 results - 601 through 625 (of 889 total)