Support

Account

Home Forums Search Search Results for 'woocommerce'

Search Results for 'woocommerce'

reply

  • Hi @reggystuffhotmail-com

    Thanks for the question.

    This will require some minimal code customization but you will need to make use of some of the ecommerce plugins available such as the Woocommerce family of plugins.

    You can also opt to search through google for some of the themes that come prepackaged with this functionality.

    Please have a look at the following page for more info on the available plugins: http://themeforest.net/category/wordpress/ecommerce/woocommerce

    I hope this info helps.

  • @toad78

    Then you need to move the if statement or duplicate it like this:

    <div class="upsells products">
    
    	<a id="trigger" class="product btn"><?php _e( 'Accessories', 'woocommerce' ) ?> <span class="glyphicon glyphicon-chevron-down">&nbsp;</span></a>
          
    		<?php 
            
                    $file = get_field('catalog');
                    
                    if( $file ) {
                    
                        $url = wp_get_attachment_url( $file );
                        
                        ?><a id="catalog" target="_blank" class="product btn" href="<?php echo $url; ?>" >DOWNLOAD CATALOG</a><?php
                    
                    }
                    
                    ?>  
    	<?php if ( $products->have_posts() ) : ?>
    		<?php woocommerce_product_loop_start(); ?>
    
    			<?php while ( $products->have_posts() ) : $products->the_post(); ?>
    
    				<?php wc_get_template_part( 'content', 'accessories' ); ?>
    
    			<?php endwhile; // end of the loop. ?>
    
    		<?php woocommerce_product_loop_end(); ?>
    	<?php
    		endif;
    		wp_reset_postdata();
    	?>
            
    </div>

    Or this one:

    <?php if ( $products->have_posts() ) : ?>
    
     	<div class="upsells products">
    
    		<a id="trigger" class="product btn"><?php _e( 'Accessories', 'woocommerce' ) ?> <span class="glyphicon glyphicon-chevron-down">&nbsp;</span></a>
    		
    <?php endif; ?>
    		
    		<?php 
            
                    $file = get_field('catalog');
                    
                    if( $file ) {
                    
                        $url = wp_get_attachment_url( $file );
                        
                        ?><a id="catalog" target="_blank" class="product btn" href="<?php echo $url; ?>" >DOWNLOAD CATALOG</a><?php
                    
                    }
                    
                    ?>  
    <?php if ( $products->have_posts() ) : ?>
    		<?php woocommerce_product_loop_start(); ?>
    
    			<?php while ( $products->have_posts() ) : $products->the_post(); ?>
    
    				<?php wc_get_template_part( 'content', 'accessories' ); ?>
    
    			<?php endwhile; // end of the loop. ?>
    
    		<?php woocommerce_product_loop_end(); ?>
            
    	</div>  
    
    <?php
    endif;
    wp_reset_postdata();
    ?>

    Hope this makes sense.

  • The Accessories are set using WooCommerce’s UpSells section. If there are no items in the UpSells, I still want the DOWNLOAD CATALOG to display.

    if ( ! defined( 'ABSPATH' ) ) {
    	exit; // Exit if accessed directly
    }
    
    ?>
    <h1 itemprop="name" class="product_title entry-title"><?php the_title(); ?></h1>
    
    <?php
    global $product, $woocommerce_loop;
    
    $upsells = $product->get_upsells();
    
    if ( sizeof( $upsells ) === 0 ) {
    	return;
    }
    
    $meta_query = WC()->query->get_meta_query();
    
    $args = array(
    	'post_type'           => 'product',
    	'ignore_sticky_posts' => 1,
    	'no_found_rows'       => 1,
    	'posts_per_page'      => $posts_per_page,
    	'orderby'             => $orderby,
    	'post__in'            => $upsells,
    	'post__not_in'        => array( $product->id ),
    	'meta_query'          => $meta_query
    );
    
    $products = new WP_Query( $args );
    
    $woocommerce_loop['columns'] = $columns;
    
    if ( $products->have_posts() ) : ?>
    
     	<div class="upsells products">
    
    		<a id="trigger" class="product btn"><?php _e( 'Accessories', 'woocommerce' ) ?> <span class="glyphicon glyphicon-chevron-down">&nbsp;</span></a>
          
    		<?php 
            
                    $file = get_field('catalog');
                    
                    if( $file ) {
                    
                        $url = wp_get_attachment_url( $file );
                        
                        ?><a id="catalog" target="_blank" class="product btn" href="<?php echo $url; ?>" >DOWNLOAD CATALOG</a><?php
                    
                    }
                    
                    ?>  
    
    		<?php woocommerce_product_loop_start(); ?>
    
    			<?php while ( $products->have_posts() ) : $products->the_post(); ?>
    
    				<?php wc_get_template_part( 'content', 'accessories' ); ?>
    
    			<?php endwhile; // end of the loop. ?>
    
    		<?php woocommerce_product_loop_end(); ?>
            
    	</div>
        
       
        
    
    <?php endif;
    
    wp_reset_postdata();
    
    ?>

    What does work, but not layout I want, is to move the DOWNLOAD CATALOG link outside the loop. But then I would have to make modifications to my CSS to force the layout that I want if there was/wasn’t any Accessories to post.

  • Well I can’t say it worked for me.

    I reinstalled the latest version (I already had it) and still nothing is posting in the frontend. It doesn’t make sense to disable the plugins because I have other ACF fields developed and they post just fine in the frontend.

    So I went in a disabled most of the plugins (all but two: ACF and Woocommerce) and still nothing posting on the frontend.

  • this is my url for one product category page ../wp-admin/edit-tags.php?action=edit&taxonomy=product_cat&tag_ID=7&post_type=product from there i take ID 7 and put there. so code will be like now <?php the_field('side_box_title', '7'); ?>

    but nothing is come. remember this is woocommerce product category page

    few code from that page

    <?php if ( apply_filters( 'woocommerce_show_page_title', true ) ) : ?>
    
    <h1 class="page-title">  <?php woocommerce_page_title(); ?></h1>
    <?php endif; ?>
    <?php
                /**
                 * woocommerce_archive_description hook
                 *
                 * @hooked woocommerce_taxonomy_archive_description - 10
                 * @hooked woocommerce_product_archive_description - 10
                 */
                do_action( 'woocommerce_archive_description' );
            ?>
            </div>
     <div class="cat-left-pan">
     <div class="cat-widget">
    <?php the_field('side_box_title', '7'); ?>
     </div>
  • I think I got it figured out:

    <?php
    		$queried_object = get_queried_object(); 
    		$taxonomy = $queried_object->taxonomy;
    		$term_id = $queried_object->term_id;  
    	?>
       		<?php if ( apply_filters( 'woocommerce_show_page_title', true ) ) : ?>
    
    			<div class="catback" style="background-image: url('<?php the_field('category_background_image', $taxonomy . '_' . $term_id); ?>');">
        
    				<h1 class="page-title"><?php woocommerce_page_title(); ?></h1>
                
          		</div>
    
    		<?php endif; ?>

    I’ve only tested it with one category, though. So I’ll be testing with more categories to see if it works.

  • Hi!

    Yep, I have solved it.

    I had to add 2nd description on category pages, so I created custom field ‘second_description’ and put this code (below) at the file woocommerce file ‘archive-product.php’

    <?php

    // vars
    $queried_object = get_queried_object();
    $taxonomy = $queried_object->taxonomy;
    $term_id = $queried_object->term_id;

    // load desc for this taxonomy term (term object)
    $sec_descrip = get_field(‘second_description’, $queried_object);

    // load desc for this taxonomy term (term string)
    $sec_descrip = get_field(‘second_description’, $taxonomy . ‘_’ . $term_id);

    ?>

    <div class=”term-description”><?php the_field( ‘second_description’, $queried_object ); ?></div>

  • This reply has been marked as private.
  • Hi @pagol

    It could be because of a plugin or theme conflict or any other things. The best way to test it out is by trying to reproduce the issue on one of the WordPress’ stock themes (like Twenty Fifteen) with only ACF and WooCommerce activated? If it disappears, then you can activate the theme and plugins one by one to see which one causes the issue.

    I hope this helps.

  • Hey John,

    Thanks again for another response!

    I’ve implemented the code and have found the following:

    1) when I create a new, clean product, with no value in the field where the multidimensional array is stored, I see the five rows in my form and the following error output:

    
    Notice: Undefined offset: 0 in /Applications/MAMP/htdocs/acf/wp-content/themes/storefront/functions.php on line 26
    
    Warning: Invalid argument supplied for foreach() in /Applications/MAMP/htdocs/acf/wp-content/themes/storefront/functions.php on line 27
    

    2) when i do create a field (via WooCommerce’s Booking plugin…the ‘_wc_booking_availability’ field, on the front-end ACF form, I see

    
    Warning: Illegal string offset 'from' in /Applications/MAMP/htdocs/acf/wp-content/themes/storefront/functions.php on line 29
    
    Warning: Illegal string offset 'from' in /Applications/MAMP/htdocs/acf/wp-content/themes/storefront/functions.php on line 29
    
    Warning: Illegal string offset 'to' in /Applications/MAMP/htdocs/acf/wp-content/themes/storefront/functions.php on line 30
    
    Warning: Illegal string offset 'to' in /Applications/MAMP/htdocs/acf/wp-content/themes/storefront/functions.php on line 30
    
    Warning: Illegal string offset 'from' in /Applications/MAMP/htdocs/acf/wp-content/themes/storefront/functions.php on line 29
    
    Warning: Illegal string offset 'from' in /Applications/MAMP/htdocs/acf/wp-content/themes/storefront/functions.php on line 29
    
    Warning: Illegal string offset 'to' in /Applications/MAMP/htdocs/acf/wp-content/themes/storefront/functions.php on line 30
    
    Warning: Illegal string offset 'to' in /Applications/MAMP/htdocs/acf/wp-content/themes/storefront/functions.php on line 30
    
    Warning: Cannot use a scalar value as an array in /Applications/MAMP/htdocs/acf/wp-content/themes/storefront/functions.php on line 29
    
    Warning: Cannot use a scalar value as an array in /Applications/MAMP/htdocs/acf/wp-content/themes/storefront/functions.php on line 30
    
    Warning: Illegal string offset 'from' in /Applications/MAMP/htdocs/acf/wp-content/themes/storefront/functions.php on line 29
    
    Warning: Illegal string offset 'from' in /Applications/MAMP/htdocs/acf/wp-content/themes/storefront/functions.php on line 29
    
    Warning: Illegal string offset 'to' in /Applications/MAMP/htdocs/acf/wp-content/themes/storefront/functions.php on line 30
    
    Warning: Illegal string offset 'to' in /Applications/MAMP/htdocs/acf/wp-content/themes/storefront/functions.php on line 30
    
    Warning: Illegal string offset 'from' in /Applications/MAMP/htdocs/acf/wp-content/themes/storefront/functions.php on line 29
    
    Warning: Illegal string offset 'from' in /Applications/MAMP/htdocs/acf/wp-content/themes/storefront/functions.php on line 29
    
    Warning: Illegal string offset 'to' in /Applications/MAMP/htdocs/acf/wp-content/themes/storefront/functions.php on line 30
    
    Warning: Illegal string offset 'to' in /Applications/MAMP/htdocs/acf/wp-content/themes/storefront/functions.php on line 30
    

    I really do appreciate your time in helping me with this so thanks again in advance. I don’t want to violate any kind of policy of ACF’s forum by soliciting services or whatnot, but would it be possible for me just to hire you to knock this out? I have the ability to create an environment and furnish access quickly.

    Thanks again!

  • I finally found a solution to this.

    I needed to have a DHL number in my orders page – so when I shipped the order, I put in the DHL number in that field and it should show up in the order.

    That’s how I did it in my functions.php:

    add_action ('woocommerce_order_details_after_order_table', 'optigem_sendungsnummer', 20);
    		
    
    	function optigem_sendungsnummer( $order ) {
    	
    	if (get_field('sendungsnummer', $order->id)) { // Only show if field is filled
     
    ?>
    		<p class="sendungsnummer">DHL: <?php the_field('sendungsnummer', $order->id);    ?><p>  		
    		<?php 
    		
    	}
    
    }
  • Hi John,

    Thanks for the response!

    I’ve been fiddling with the code that you sent. The good news is with your code, I’m able to get empty rows to show in the repeater field. The not-so-good news is I’m still not able to pre-populate the form rows with values on the front end, nor post the values to the correct pre-existing field.

    I’ve noticed that the pre-existing field (‘availability’ field, we’re using WooCommerce Bookings) is wrapping the item in an extra array, such as:

    
    Array ( [0] => Array ( [0] => Array ( [type] => custom [bookable] => yes [priority] => 10 [from] => 2016-02-02 [to] => 2016-02-03 ) [1] => Array ( [type] => custom [bookable] => no [priority] => 10 [from] => 2016-02-10 [to] => 2016-02-12 ) [2] => Array ( [type] => custom [bookable] => no [priority] => 10 [from] => 2016-02-04 [to] => 2016-02-20 ) ) ) 
    

    …whereas, the array output from ACF using your code is:

    
    Array ( [0] => Array ( [type] => custom [bookable] => yes [priority] => 10 [from] => 2016-02-02 [to] => 2016-02-03 ) [1] => Array ( [type] => custom [bookable] => no [priority] => 10 [from] => 2016-02-10 [to] => 2016-02-12 ) [2] => Array ( [type] => custom [bookable] => no [priority] => 10 [from] => 2016-02-04 [to] => 2016-02-20 ) ) 
    

    The code I’m using so far:

    
    <?php
    /**
     * The template for displaying full width pages.
     *
     * Template Name: ACF Front End Repeater Form
     *
     * @package storefront
     */
    ?>
    <?php $post_id = 55; ?>
    <?php acf_form_head(); ?>
    <?php get_header(); ?>
    
    	<div id="primary" class="content-area">
    		<main id="main" class="site-main" role="main">
    
    		<?php
    			
    		add_filter('acf/load_value/name=my_repeater_field','load_my_repeater_field_value', 10, 3);
    		
    		function  load_my_repeater_field_value($value, $post_id, $field) {
    			/* 
    				--> adding the array() around get_post_meta() makes this output array match the default one (see line 57 below please), but it does not render form rows
    				
    				$load_value =  maybe_unserialize(get_post_meta($post_id, '_wc_booking_availability', true)); 
    			*/
    			$load_value =  maybe_unserialize(get_post_meta($post_id, '_wc_booking_availability', true));
    			return $load_value;
    			/* 
    				--> tried this, but it added extra empty rows somehow
    
    				return call_user_func_array('array_merge', $load_value);
    			*/
    		};
    		
    		?>
    			
    			<?php
    				$options = array(
    					'post_id' => $post_id,
    					'post_title' => true,
    					'field_groups' => array(
    						18,
    					),
    					'submit_value' => __("Update", 'acf'),
    					'updated_message' => __("Post updated", 'acf'),
    					'uploader' => 'wp'
    				);
    			?>
    			<?php acf_form($options); ?>
    			<?php 
    			add_filter('acf/save_post', 'update_my_repeater_field_value', 20);
    			function update_my_repeater_field_value($post_id) {
    				// check the post type
    				// you don't want to do this on every post type
    				if (get_post_type($post_id) != 'product') {
    					return;
    				}
    				$value = get_field('my_repeater_field', $post_id);
    				update_post_meta($post_id, '_wc_booking_availability', $value);
    			} // when i submit the field, the ACF array (output below) deletes all the values
    			?>
    			
    			<?php
    				// Printing both the pre-existing field and the ACF field arrays for debugging/testing
    				
    				// ACF
    				$acf_repeater_array = get_field( "my_repeater_field", $post_id);
    				echo 'ACF repeater field array:<br><br>';
    				if( empty( $acf_repeater_array ) ){
    					echo '<strong>Empty</strong><br><br>';
    				} else {
    					print_r(array_values($acf_repeater_array)); // this doesn't match the array for the pre-existing field unless i wrap get_post_meta() in an array() on line 25
    					echo '<br><br><hr>';
    				};
    			
    				// Pre-existing field
    				$pre_existing_array = get_post_meta( $post_id, '_wc_booking_availability' );
    				echo  'Pre-existing field array:<br><br>';
    				if( empty( $pre_existing_array ) ){
    					echo '<strong>Empty</strong><br><br>';
    				} else {
    					print_r(array_values($pre_existing_array));
    					echo '<br><br><hr>';
    					echo 'Pre-existing field array (when I \'flatten\' the pre-existing array):<br><br>';
    					$flat = call_user_func_array('array_merge', $pre_existing_array);
    					print_r(array_values($flat)); // this DOES match the array for the pre-existing field 
    					echo '<br><br><hr>';
    				};
    			?>
    
    		</main><!-- #main -->
    	</div><!-- #primary -->
    
    <?php get_footer(); ?>
    
    

    I’m at the point where I don’t know if I’m making progress or just getting more lost, so huge, huge thanks in advance for any insights!

  • I’m having the same issue.

    Scenario for context:
    I have woocommerce installed with variable products having 2-3 attributes that change for each variation, BUT for each attribute A there is only one possible attribute B, C etc.
    So I only need attribute A to be selectable by end user, but all of them visible.
    I need them separate for sake of filtering.

    I tried to set variable B, C etc as an ACF group and assign them to post_type equal to product_variation and expected to see them into the dropdown for each variant along with weight, dimensions and so on, but there is nothing.

    Am I doing something wrong? Is there an ETA on this issue?

    Thanks a lot in advance

  • RELATED: Any chance someone can direct me on how to hook these fields into the Woocommerce Single Product page? Right now the code is simply added to the single-product.php, immediately following the woocommerce_content, but it’s not actually appearing where I want it to. I suspect I need to use some sort of hook with that code added to it.

  • Nothing, eh? Always fun when a simple core update to WP or WooCommerce totally incapacitates a plugin. Will have to disable this completely for now I guess and navigate away, one less dependency that can spontaneously combust.

  • Thanks for your response.
    Here is the filter I am using, (I am using it with WooCommerce products) and I am not using type of ‘DATE’ (although I did try when I couldn’t get the following to work)

    	$orderby_value = isset( $_GET['orderby'] ) ? wc_clean( $_GET['orderby'] ) : apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby' ) );
    	switch( $orderby_value ) {
    	
    		case 'release_date':
    			$sort_args['orderby']  = 'meta_value';
    			$sort_args['order']    = 'desc';
    			$sort_args['meta_key'] = 'release_date';
    			break;
    		
    	}
    	
    	return $sort_args;
  • please use code tags when posting code.

    I’m not sure exactly what you’re doing, but if you want to set the default value of a field then I think you need to use the acf/load_field filter. the acf/update_value runs when before the acf field is saved, not when the field is loaded.

    http://www.advancedcustomfields.com/resources/acfload_field/

    You can’t change the default value of an ACF field when you’re saving a product in woocommerce.

    Also, looking at what I can make out of your code $order->id has no meaning inside of the function.

    $post_id = $order->id; is setting $post_id to NULL.

  • Simple answer is no. You can’t have fields for woocommerce and acf with the same name. Custom field names need to be unique if they are used on the same post.

  • I dug into this one more and found the culprit. The Store Exporter Deluxe plugin adds a “attribute_escape” filter, which ends up overriding the esc_attr call that ACF makes when it outputs the value of a field. The filter specifically removes the equals symbol from the value, which explains why we’re getting an empty string for the “is equals to” value. This filter is applied in the /plugins/woocommerce-store-exporter-deluxe/includes/formatting.php file. I commented out the filter for now and ACF is back to working as expected. I’ll reach out to the other developer to see if he can clean up this issue, though maybe there’s something that ACF can do to prevent other plugins from overriding the esc attributes like this.

  • Here’s my list of active plugins. I have the Deluxe version of the store exporter. Maybe that’s the difference. I can zip that up and send it over for testing is needed.

    – Advanced Custom Fields Pro: by elliot condon – 5.3.2.2
    – AJAX Thumbnail Rebuild: by junkcoder – 1.12
    – Enable Media Replace: by Måns Jonasson – 3.0.3
    – Gravity Forms + Custom Post Types: by Brad Vincent – 3.0.1
    – Gravity Forms: Notification Attachments: by Timothy Wood (@codearachnid) – 1.5
    – Groups WooCommerce: by itthinx – 1.9.1
    – LearnDash WooCommerce Integration: by LearnDash – 1.2
    – Peter’s Login Redirect: by Peter Keung – 2.9.0
    – Post Types Order: by Nsp Code – 1.8.5
    – Redirection: by John Godley – 2.4.3
    – LearnDash LMS: by LearnDash – 2.1.5
    – Smart Manager: by Store Apps – 3.9.10
    – SumoMe: by SumoMe – 1.10
    – Twitter Widget Pro: by Aaron D. Campbell – 2.8.0
    – Visser Labs Updater: by Visser Labs – 1.2
    – WooCommerce – Autocomplete Order: by Mirko Grewing – 1.1.1
    – WooCommerce Deposits: by Abdullah Ali – 1.5
    – WooCommerce Dynamic Pricing: by Lucas Stark – 2.10.5
    – Follow-Up Emails: by 75nineteen Media LLC – 4.4.7
    – WooCommerce Moneris Gateway: by WooThemes / SkyVerge – 2.3.4
    – WooCommerce Google Analytics Integration: by WooThemes – 1.3.0
    – WooCommerce Product Add-ons: by WooThemes – 2.7.12 – 2.7.13 is available
    – WooCommerce Purolator: by Guillaume Prieur – 2.1.9
    – WooCommerce – Store Exporter Deluxe: by Visser Labs – 2.0.3
    – WooCommerce Subscriptions: by Prospress Inc. – 2.0.6
    – WooCommerce: by WooThemes – 2.4.10
    – WP Crontrol: by John Blackbourn & Edward Dale – 1.3
    – WP Instagram Widget: by Scott Evans – 1.8.1
    – WP Super Cache: by Automattic – 1.4.6
    – Gravity Forms: by rocketgenius – 1.9.14
    – Gravity Forms MailChimp Add-On: by rocketgenius – 3.7.1
    – Post Duplicator: by Metaphor Creations – 2.12
    – Groups: by itthinx – 1.9.0
    – Multisite User Management: by Brent Shepherd – 1.1
    – WooThemes Helper: by WooThemes – 1.5.9
    – iThemes Security Pro: by iThemes – 2.0.2
    – BuddyPress Community Stats: by rich @etiviti – 0.5.4
    – Advanced Custom Fields Pro: by elliot condon – 5.3.2.2
    – WP Super Cache: by Automattic – 1.4.6
    – Yoast SEO: by Team Yoast – 3.0.3
    – wpMandrill: by Mandrill – 1.33
    – Network Plugin Auditor: by Katherine Semel – 1.9.1

  • You’re going to hate me, but… I have a test site that I keep around for testing WooCommerce stuff. It has

    – WP 4.3.1
    – ACF 5.3.2.2
    – WooCommerce 2.4.10

    and I installed WooCommerce – Store Exporter 1.8.3

    I’m not saying that it’s not going away when deactivating this plugin, but with just these 3 plugins I’m not seeing an issue.

    What other plugins do you each have installed on the site, there must be something else in common.

    (Also, just a side note, the store exporter is not compatible with ACF5, only ACF4. Meaning it won’t export custom fields created with ACF5.)

  • @prima

    In what way do you mean to get it working on the front end?
    The original question is about adding WooCommerce product attributes through ACF fields when creating a produkt.

  • I don’t know it this is something that will be fixed or not. As a general rule I don’t use any plugin functions for ACF until after the init action.

    First thing is that you need to get the value inside your function because the value of outside the function will have no effect on the value inside the function.

    Since you have to get the value in the function anyway I would change the code to something like this:

    
     
      function disable_ups_ground_by_state( $rates ) {
        $disabled_ground = get_field('ground_disable_for_states', 'option');
        if (!$disabled_ground) {
          return;
        }
        global $woocommerce;
        // you also need to test to see if it's an array
        // before convering it ot an array
        if (!is_array($disabled_ground)) {
          $disabled_ground = array($disabled_ground);
        }
        if( in_array( $woocommerce->customer->get_shipping_state(), $disabled_ground ) ) {
          unset($rates['ups:03']);
        }
        return $rates;
      }
      add_filter( 'woocommerce_package_rates', 'disable_ups_ground_by_state', 10 );
     
    
  • I don’t know much about WooCommerce groups, but ACF provides a way to create your own rules for displaying fields.

    http://www.advancedcustomfields.com/resources/custom-location-rules/

  • There must be some reason that it’s returning an id instead of the URL. There’s been another question with the same problem recently… in the last few months.

    but I can’t find it. If the same field is returning a url in one place but an id in another then you’re got some kind of compatibility issue. You should deactivate other plugins and see what’s causing it because it will just keep giving you problems. The last time I’m pretty sure it had to do with a woocommerce add on, but it could be anything.

Viewing 25 results - 776 through 800 (of 889 total)