ایجاد تب در ووکامرس و تغییرات

harbiline

Edris
سلام

تو ووکامرس برای اینکه بخواییم یه تب جدید بذاریم باید تو فانکشن قالب این کد رو بذاریم

add_filter( 'woocommerce_product_tabs', 'woo_new_product_tab' );
function woo_new_product_tab( $tabs ) {

// Adds the new tab

$tabs['test_tab'] = array(
'title' => __( 'New Product Tab', 'woocommerce' ),
'priority' => 50,
'callback' => 'woo_new_product_tab_content'
);

return $tabs;

}
function woo_new_product_tab_content() {

// The new tab content

echo '<h2>New Product Tab</h2>';
echo '<p>Here\'s your new product tab.</p>';

}




خب تا اینجا درست ...تو فانکشن رفت و تو ووکامرس هم نشون میده - اما مثله مهم تر اون اینه ک من اگر بخوام تغییرات بدم مثلا بهش جعبه دانلود بذارم با کد

<?php $mid_var = get_post_meta($post->ID, 'نام',true);
if(isset($mid_var) && !empty($mid_var)) : ?>
<li id="format-image"><strong>نام :&nbsp </strong></strong><font color="#0093C4"> <?php echo get_post_meta($post->ID, 'نام',true); ?></font>&nbsp </li>
<?php endif; ?>


تو بخش

    echo '<h2>New Product Tab</h2>';
    echo '<p>Here\'s your new product tab.</p>';

 بذارم سایت کلا دیگ بالا نمی یاد

خواستار :

میخوام جوری باشه که مثلا تو تب ووکامرس ک جدید میشه هرچی کد php که دلم بخواد بذارم روش شما چیه؟

 

Mohammad

مدیر انجمن
پرسنل مدیریت
چه خطایی براتون رخ میده؟

فرستاده شده از HUAWEI MT7-L09ِ من با Tapatalk

 

harbiline

Edris
چه خطایی براتون رخ میده؟

فرستاده شده از HUAWEI MT7-L09ِ من با Tapatalk
 
کلا تو فانکشن نمیشه مثل برگه ها کد نوشت برای یک قسمت خاص ..تو فانکشن من مثلا کدی مثیزنم  ک جدیدترین محصول رو بده تو تب کل سایت و فانکشن بهم میریزه

 

Mohammad

مدیر انجمن
پرسنل مدیریت
اینو ازمایش کن

کد:
add_filter( 'woocommerce_product_tabs', 'woo_new_product_tab' );
function woo_new_product_tab( $tabs ) {
	
	// Adds the new tab
	
	$tabs['test_tab'] = array(
		'title' 	=> __( 'New Product Tab', 'woocommerce' ),
		'priority' 	=> 50,
		'callback' 	=> 'woo_new_product_tab_content'
	);

	return $tabs;

}
function woo_new_product_tab_content() {

	$mid_var = get_post_meta($post->ID, 'نام',true);
	if(isset($mid_var) && !empty($mid_var)) {
	echo '<li id="format-image"><strong>نام :&nbsp </strong></strong><font color="#0093C4">'.get_post_meta($post->ID, "نام",true).'</font>&nbsp </li>';
	}

	
}
 
بالا