Home Forums WoodMart support forum Custom/duplicate upsells products

Custom/duplicate upsells products

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #154003

    John
    Participant

    Hello again,
    So I’m trying to add to linked products one more tab (and also on frontend one more slider) but without luck.
    I have tried to add this code snippet on backend is working perfectly but on frontend doesn’t display anything.

    // Display a custom select field in "Linked Products" section
    add_action( 'woocommerce_product_options_related', 'display_linked_products_data_custom_field' );
    function display_linked_products_data_custom_field() {
        global $product_object, $post;
        ?>
        <p class="form-field">
            <label for="subscription_toggle_products"><?php _e( 'Subscription Toggle Products', 'woocommerce' ); ?></label>
            <select class="wc-product-search" multiple="multiple" style="width: 50%;" id="subscription_toggle_ids" name="_subscription_toggle_ids[]" data-placeholder="<?php esc_attr_e( 'Search for a product&hellip;', 'woocommerce' ); ?>" data-action="woocommerce_json_search_products_and_variations" data-exclude="<?php echo intval( $post->ID ); ?>">
                <?php
                    $product_ids = $product_object->get_meta( '_subscription_toggle_ids' );
    
                    foreach ( $product_ids as $product_id ) {
                        $product = wc_get_product( $product_id );
                        if ( is_object( $product ) ) {
                            echo '<option value="' . esc_attr( $product_id ) . '"' . selected( true, true, false ) . '>' . wp_kses_post( $product->get_formatted_name() ) . '</option>';
                        }
                    }
                ?>
            </select>
        </p>
        <?php
    }
    
    // Save the values to the product
    add_action( 'woocommerce_admin_process_product_object', 'save_linked_products_data_custom_field_value', 10, 1 );
    function save_linked_products_data_custom_field_value( $product ){
        $data = isset( $_POST['_subscription_toggle_ids'] ) ? array_map( 'intval', (array) $_POST['_subscription_toggle_ids'] ) : array();
        $product->update_meta_data( '_subscription_toggle_ids', $data );
    }
    
    add_action( 'woocommerce_after_single_product_summary', 'display_linked_products_btn', 1 );
     
    function display_linked_products_btn(){
    	echo get_post_meta( $post->ID, '_subscription_toggle_ids', true );
    }

    So i need an advice on how do duplicate upsells products. Thanks in advance. Maybe you can help me

    #154065

    Hello,

    For the additional tab you can use “Additional tab title” and “Additional tab content” options from Theme Settings >> Product Page >> TABS:

    Screenshot for clarification: https://jmp.sh/EM0NPNB

    For adding slider you can use the WoodMart slider or revolution slider using Wp-Bakery page builder inside the description tab or in the additional tab.

    You can configure upsells products to show on some particular products. Read more information in the WooCommerce documentation https://docs.woocommerce.com/document/related-products-up-sells-and-cross-sells/

    Best Regards.

    #154522

    John
    Participant

    Hello, you misunderstand what I wanted to do, but I have changed my mind.
    Now i using this hook to move the upsells after add to cart area. But this happens:
    https://imgur.com/a/IfoYVEV – because i have sticky add to cart activated.
    This is the hook that i used:

    function woodmart_remove_upsells() {
    	remove_action( 'woodmart_before_sidebar_area', 'woocommerce_upsell_display', 20 );
    	remove_action( 'woodmart_woocommerce_after_sidebar', 'woocommerce_upsell_display', 10 );
    }
    add_action( 'wp', 'woodmart_remove_upsells', 1100 );
    add_action( 'woocommerce_after_add_to_cart_form', 'woocommerce_upsell_display', 1 );

    Any advice? Thanks in advance

    #154593

    Hello,

    Sorry it requires customization and this is beyond our limitations and support policy.

    You can try with deactivating the “sticky add to cart” and then use that hook.

    Best Regards.

    #154594

    John
    Participant

    Hmm..I saw your area is defined as woodmart_after_add_to_cart_area but if I add that cu custom function nothing happens…

    So any chance to help me sort this? Like i said it just a simple movement of upsells bellow add to cart content. 🙂 Thanks
    other topics: https://xtemos.com/forums/topic/no-after-add-to-cart-button-text-area-content/

    #154606

    Hello,

    Yes, you can use html block short codes in that “after or before add to cart area” but unfortunately related products does not have an element so we could not use it in html block using Wp-Bakery page builder and then use the code of that html block in After “Add to cart button” text area.

    That’s why it is not possible with the theme options and only can be achieved with customization.

    Best Regards.

Viewing 6 posts - 1 through 6 (of 6 total)