• Resolved ilyapokrov

    (@ilyapokrov)


    Hello.

    I have 2 questions for you regarding related products in the product card.

    1) I added another description to the product card using the code below. I want this description to be displayed only on the archive pages and the Characteristics tab in the product card. But the problem is that this description was inherited and is now displayed in the product card in related products. How can I tell it not to appear in this place?

    add_action( 'woocommerce_product_options_general_product_data', 'art_woo_add_custom_fields' );
    function art_woo_add_custom_fields() {
    	global $product, $post;
    	?>
    	<div class="options_group">
    		<h2><strong>Дополнительное описание для отображения в каталоге</strong></h2>
    		<?php
    		wp_editor(get_post_meta( $post->ID, '_custom_desc', true ), 'custom_desc', array(
    			'wpautop'       => 1,
    			'media_buttons' => 1,
    			'textarea_name' => 'custom_desc',
    			'textarea_rows' => 5,
    			'tabindex'      => null,
    			'editor_css'    => '<style>.quicktags-toolbar, .wp-editor-tools, .wp-editor-wrap, .wp-switch-editor {padding: 5px 10px;} .wp-editor-container textarea.wp-editor-area {border: 1px solid #e5e5e5; height: 175px; margin-bottom:10px;}</style>',
    			'editor_class'  => 'form-field',
    			'teeny'         => 0,
    			'dfw'           => 0,
    			'tinymce'       => 1,
    			'quicktags'     => 1,
    			'drag_drop_upload' => false
    		) );
    		
    		?>
    	</div>
    	<?php
    }
    add_action( 'woocommerce_process_product_meta', 'art_woo_custom_fields_save', 10 );
    function art_woo_custom_fields_save( $post_id ) {
    	// Сохранение области тектса
    	$woocommerce_textarea = $_POST['custom_desc'];
    	if ( ! empty( $woocommerce_textarea ) ) {
    		update_post_meta( $post_id, '_custom_desc', $woocommerce_textarea );
    	}
    
    }
    
    add_action( 'woocommerce_after_shop_loop_item_title', 'art_get_fields_tab_additional_information', 4 );
    add_action( 'woocommerce_product_additional_information', 'art_get_fields_tab_additional_information' );
    remove_action( 'woocommerce_product_additional_information', 'wc_display_product_attributes', 10 );
    function art_get_fields_tab_additional_information() {
    	global $post;
    	$custom_desc= get_post_meta( $post->ID, '_custom_desc', true );
    	?>
    <span class="custom-attributes"><?php echo $custom_desc; ?></span>
    	<?php
    }

    2) How can I indicate the number of related items on the product card? For example, I want to display not 4 products, but 6 products.

    Thanks!

    • This topic was modified 5 years, 10 months ago by ilyapokrov.
    • This topic was modified 5 years, 10 months ago by ilyapokrov.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Related products’ is closed to new replies.