我正在尝试在过滤器挂钩中获取选项值的值。我尝试过以下风声
function custom_cart_item_thumbnail( $thumbnail, $cart_item, $cart_item_key ){
// // Only for Mini Cart
// if( is_cart() ) return $thumbnail;
$product = $cart_item['data'];
$product_id = $product->get_id();
$cart_item_count = WC()->cart->get_cart_contents_count();
$templateId = 9;
$templateId = get_option( 'current_templateid', true );
$productId = $cart_item['product_id'];
// Get the image src
$image_url = wp_get_attachment_image_src( get_post_thumbnail_id( $productId ), 'single-post-thumbnail' );
if ( is_multisite() ) {
$site = get_current_site();
$siteID = $site->id;
$customSrc = 'http://myurl.com?reqmethod=generateProductImage&pid='.$productId.'_'.$siteID.'&productImage='.$image_url[0].'&templateId='.$templateId;
}
else {
$customSrc = 'http://myurl.com?reqmethod=generateProductImage&pid='.$productId.'_0&productImage='.$image_url[0].'&templateId='.$templateId;
}
$thumbnail = '<img src="'.$customSrc.'" alt="icon" />';
return $thumbnail;
}
add_filter( 'woocommerce_cart_item_thumbnail', 'custom_cart_item_thumbnail', 30, 3 );
但是我无法在URL中获得选项值。有任何问题或任何其他方式可以做到这一点。请帮忙。