Support

Account

Forum Replies Created

  • John, and those struggling to piece together the different parts of this solution together, Here is how to display it on the ‘single-product.php’ page.

    Add the following, or similar, function to ‘functions.php’.

    /*----------------------------------------------*/
    /* Displays ACF fields 'Frame Type' and 'Lens Type' 
    /* Displays on SINGLE PRODUCT page and QUICK VIEW via archive
    /* DEPENDENCIES: ACF Custom Fields
    /* $variations are outputted by "variation.php"
    /*----------------------------------------------*/
    function frame_style_lens_colour ( $variations ) {
    	$variations['frame_type'] = get_field('frame_type', $variations[ 'variation_id' ]);
    	$variations['lens_type'] = get_field('lens_type', $variations[ 'variation_id' ]);
    	
    	return $variations;
    }
    add_filter ( 'woocommerce_available_variation', 'frame_style_lens_colour ', 10, 1 );

    THEN copy ‘variation.php’ to your theme or child theme.
    Add the following to the file, or similar, and save it:

    <p><strong>Lens Style:</strong> {{{ data.variation.lens_type }}} Polarized Lens </p>
    <p><strong>Frame Style:</strong> {{{ data.variation.frame_type }}} </p>

    Now your variation specific ACF fields will appear on the front end of the website.

  • John, and those struggling to piece together the different parts of this solution together, Here is how to display it on the ‘single-product.php’ page.

    Add the following, or similar, function to ‘functions.php’.

    /*----------------------------------------------*/
    /* Displays ACF fields 'Frame Type' and 'Lens Type' 
    /* Displays on SINGLE PRODUCT page and QUICK VIEW via archive
    /* DEPENDENCIES: ACF Custom Fields
    /* $variations are outputted by "variation.php"
    /*----------------------------------------------*/
    function frame_style_lens_colour ( $variations ) {
    	$variations['frame_type'] = get_field('frame_type', $variations[ 'variation_id' ]);
    	$variations['lens_type'] = get_field('lens_type', $variations[ 'variation_id' ]);
    	
    	return $variations;
    }
    add_filter ( 'woocommerce_available_variation', 'frame_style_lens_colour ', 10, 1 );

    THEN copy ‘variation.php’ to your theme or child theme.
    Add the following to the file, or similar, and save it:

    <p><strong>Lens Style:</strong> {{{ data.variation.lens_type }}} Polarized Lens </p>
    <p><strong>Frame Style:</strong> {{{ data.variation.frame_type }}} </p>

    Now your variation specific ACF fields will appear on the front end of the website.

  • Yes, the $today was declared further up in the code so I didn’t include it in my snippet.

    I ended up using this code and it seems to work perfectly.

    $treasure_bag_date = get_sub_field('treasure_bag_date');  
    $today = date('Ymd');
    $next_week = date_create($treasure_bag_date);
    $next_week = date_add($next_week, date_interval_create_from_date_string('7 days'));
    $next_week = date_format($next_week, 'Ymd');?>
    			
    <?php // set #active_week to current week ?>
    <tr <?php if( ($today >= $treasure_bag_date) && ($today <= $next_week) ){ echo "id='active_week'"; }?>>
  • I’m very sorry for the time it has taken to respond to your reply.

    I’ve used your example with a few changes:

    // date starting the week of loaded treasure bag
    $treasure_bag_date = get_sub_field('treasure_bag_date', 85);
    $last_week = $treasure_bag_date-6;
    $next_week = $treasure_bag_date+6;
    
    <tr <?php if( ($treasure_bag_date >= $last_week) && ($treasure_bag_date <= $next_week) ){ echo "id='active_week'"; }?>>

    The code is echoing all the weeks.

    Here is an example https://www.gymbaroomteliza.com/treasure_bag/

Viewing 5 posts - 1 through 5 (of 5 total)