כדי להוסיף תיאור שני לקטגוריות מוצרים ב-Woocommerce, יש להוסיף זוג פונקציות ואם מדובר באלמנטור, אז צריך להוסיף קצרקוד אלמנטור.

חשוב! עריכה של קבצי מקור של התבנית צריכה להיות לאחר וידוא שיש גיבוי, כי טעות אחת קטנה יכולה לגרום לאתר לא לעלות.
כמו כן, לוודא שכל שינוי כזה מתועד בקובץ TXT בתיקיית ה-Programming של הלקוח.
הוספת שדה תיאור שני:
/**
 * @snippet Add new textarea to Product Category Pages - WooCommerce
 */ 
 
// ---------------
// 1. Display field on "Add new product category" admin page
 
add_action( 'product_cat_add_form_fields', 'bbloomer_wp_editor_add', 10, 2 );
 
function bbloomer_wp_editor_add() {
 ?>
 <div class="form-field">
 <label for="seconddesc"><?php echo __( 'Second Description', 'woocommerce' ); ?></label>
 
 <?php
 $settings = array(
 'textarea_name' => 'seconddesc',
 'quicktags' => array( 'buttons' => 'em,strong,link' ),
 'tinymce' => array(
 'theme_advanced_buttons1' => 'bold,italic,strikethrough,separator,bullist,numlist,separator,blockquote,separator,justifyleft,justifycenter,justifyright,separator,link,unlink,separator,undo,redo,separator',
 'theme_advanced_buttons2' => '',
 ),
 'editor_css' => '<style>#wp-excerpt-editor-container .wp-editor-area{height:175px; width:100%;}</style>',
 );
 
 wp_editor( '', 'seconddesc', $settings );
 ?>
 
 <p class="description"><?php echo __( 'This is the description that goes BELOW products on the category page', 'woocommerce' ); ?></p>
 </div>
 <?php
}
 
// ---------------
// 2. Display field on "Edit product category" admin page
 
add_action( 'product_cat_edit_form_fields', 'bbloomer_wp_editor_edit', 10, 2 );
 
function bbloomer_wp_editor_edit( $term ) {
 $second_desc = htmlspecialchars_decode( get_woocommerce_term_meta( $term->term_id, 'seconddesc', true ) );
 ?>
 <tr class="form-field">
 <th scope="row" valign="top"><label for="second-desc"><?php echo __( 'Second Description', 'woocommerce' ); ?></label></th>
 <td>
 <?php
 
 $settings = array(
 'textarea_name' => 'seconddesc',
 'quicktags' => array( 'buttons' => 'em,strong,link' ),
 'tinymce' => array(
 'theme_advanced_buttons1' => 'bold,italic,strikethrough,separator,bullist,numlist,separator,blockquote,separator,justifyleft,justifycenter,justifyright,separator,link,unlink,separator,undo,redo,separator',
 'theme_advanced_buttons2' => '',
 ),
 'editor_css' => '<style>#wp-excerpt-editor-container .wp-editor-area{height:175px; width:100%;}</style>',
 );
 
 wp_editor( $second_desc, 'seconddesc', $settings );
 ?>
 
 <p class="description"><?php echo __( 'This is the description that goes BELOW products on the category page', 'woocommerce' ); ?></p>
 </td>
 </tr>
 <?php
}
 
// ---------------
// 3. Save field @ admin page
 
add_action( 'edit_term', 'bbloomer_save_wp_editor', 10, 3 );
add_action( 'created_term', 'bbloomer_save_wp_editor', 10, 3 );
 
function bbloomer_save_wp_editor( $term_id, $tt_id = '', $taxonomy = '' ) {
 if ( isset( $_POST['seconddesc'] ) && 'product_cat' === $taxonomy ) {
 update_woocommerce_term_meta( $term_id, 'seconddesc', esc_attr( $_POST['seconddesc'] ) );
 }
}
 
// ---------------
// 4. Display field under products @ Product Category pages - אופציה להצגה מיד אחרי המוצרים ללא הקצרקוד
 
// add_action( 'woocommerce_after_shop_loop', 'bbloomer_display_wp_editor_content', 5 );
 
/* function bbloomer_display_wp_editor_content() {
 if ( is_product_taxonomy() ) {
 $term = get_queried_object();
 if ( $term && ! empty( get_woocommerce_term_meta( $term->term_id, 'seconddesc', true ) ) ) {
 echo '<p class="term-description">' . wc_format_content( htmlspecialchars_decode( get_woocommerce_term_meta( $term->term_id, 'seconddesc', true ) ) ) . '</p>';
 }
 }
}*/
הוספת קצרקוד אלמנטור שיציג את התיאור השני: (להוסיף בבילדר תבנית)
// Shortcode to output custom PHP in Elementor
function wpc_elementor_shortcode() {
 $term = get_queried_object();
 $second_desc = htmlspecialchars_decode( get_woocommerce_term_meta( $term->term_id, 'seconddesc', true ) );
 echo $second_desc;
 //echo 'This Works 5.';
}
add_shortcode( 'my_elementor_php_output', 'wpc_elementor_shortcode');
מקור / רפרנס:
https://businessbloomer.com/woocommerce-add-a-second-content-box-product-category-pages/
נוספים:
https://www.webhat.in/article/woocommerce-tutorial/adding-custom-fields-to-woocommerce-product-category/
https://wordpress.org/support/topic/creating-custom-field-in-woocommerce-categories/
https://stackoverflow.com/questions/23469841/adding-custom-field-to-product-category
https://stackoverflow.com/questions/37181575/how-do-i-add-custom-fields-to-the-categories-in-woocommerce
x
סייען נגישות
הגדלת גופן
הקטנת גופן
גופן קריא
גווני אפור
גווני מונוכרום
איפוס צבעים
הקטנת תצוגה
הגדלת תצוגה
איפוס תצוגה

אתר מונגש

אנו רואים חשיבות עליונה בהנגשת אתר האינטרנט שלנו לאנשים עם מוגבלויות, וכך לאפשר לכלל האוכלוסיה להשתמש באתרנו בקלות ובנוחות. באתר זה בוצעו מגוון פעולות להנגשת האתר, הכוללות בין השאר התקנת רכיב נגישות ייעודי.

סייגי נגישות

למרות מאמצנו להנגיש את כלל הדפים באתר באופן מלא, יתכן ויתגלו חלקים באתר שאינם נגישים. במידה ואינם מסוגלים לגלוש באתר באופן אופטימלי, אנה צרו איתנו קשר

רכיב נגישות

באתר זה הותקן רכיב נגישות מתקדם, מבית all internet - בניית אתרים. רכיב זה מסייע בהנגשת האתר עבור אנשים בעלי מוגבלויות.