I am building a woocommerce details page. Mostly without much front-end woocommerce functions. On the details page I have (6) stores inventory potentially using this layout – one product displayed at a time.
There are certain details that have to be store specific, ie phone, location, and carfax id. I’ve stored the corresponding id/data in a custom plugin seen as the "get_option"
below.
Obviously below code won’t work – but its close to my goal:
$product=>attribute['dealer-location'] = 'x' echo options($q,$r,$s);
I feel the below code is horribly inefficient – and because of the use of headway I have to use this every time I have a new block and want to get the phone or review ID. Worried I’ll add ~1-2seconds
on load waiting for all this to find replace(s) before page load.
<?php
global $product;
$attributes = $product->get_attributes();
$dealerlookup = $attributes['dealer-location'];
$dealerlookupid = $dealerlookup['value'];
//if ($dealerlookup = 'acuraofspring')
// $cat_id = get_option( 'aos-review-cat-id' );
// if ($dealerlookup = 'jwacura') {
// $cat_id = get_option( 'akc-review-cat-id' );
// }
// else {
// $cat_id = '555';
// }
$aosdealerid = get_option( 'aos-review-cat-id' );
$akcdealerid = get_option( 'akc-review-cat-id' );
$hkcdealerid = get_option( 'hkc-review-cat-id' );
$tkcdealerid = get_option( 'tkc-review-cat-id' );
$twcdealerid = get_option( 'twc-review-cat-id' );
$outdealerid = get_option( 'out-review-cat-id' );
$dealercommon = array ("acuraofspring","jwacura","jwautooutlet", "jwhonda", "jwtoyotawc", "jwtoyotakc");
$dealerreviewid = array ($aosdealerid,$akcdealerid, $outdealerid, $hkcdealerid, $twcdealerid, $tkcdealerid);
$cat_id = str_replace($dealercommon,$dealerreviewid,$dealerlookupid);
echo $cat_id;
$args=array(
'cat' => $cat_id,
'post_type' => 'dealer-review',
'post_status' => 'publish',
'posts_per_page' => 4,
'caller_get_posts'=> 1
);