a
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudanti.
a
Follow Me
Search
Change my downloads template if product link is invalid - WooCommerce MultiSite Global Cart
14574
documentation-template-default,single,single-documentation,postid-14574,cookies-not-set,eltd-core-1.1,woocommerce-no-js,awake child-child-ver-1.0.0,awake-ver-1.0,eltd-smooth-scroll,eltd-smooth-page-transitions,eltd-mimic-ajax,eltd-grid-1200,eltd-blog-installed,eltd-default-style,eltd-fade-push-text-top,eltd-header-standard,eltd-sticky-header-on-scroll-down-up,eltd-default-mobile-header,eltd-sticky-up-mobile-header,eltd-menu-item-first-level-bg-color,eltd-dropdown-slide-from-top,eltd-,eltd-fullscreen-search eltd-search-fade,eltd-side-menu-slide-from-right,wpb-js-composer js-comp-ver-5.0.1,vc_responsive
 

Change my downloads template if product link is invalid

WooCommerce MultiSite Global Cart / Change my downloads template if product link is invalid
Share on FacebookTweet about this on TwitterShare on Google+Share on LinkedInShare on TumblrPin on PinterestEmail this to someonePrint this page

Change my downloads template if product link is invalid

An order from a shop in the network become visible for customer through My Account -> Orders in all shops  once the WooCommerce Multisite Global Cart plugin is activated. Some themes are not MultiSite capable, so downloadable Product link might be invalid:

 

The default template file used for this area is located within your theme at /woocommerce/order/order-downloads.php If the file dos not exists, it should be copied from WooCommerce plugin, from /templates/order/order-downloads.php

The order-downloads.php file contain the following:

...

switch ( $column_id ) {
    case 'download-product' : ?>
        <a href="<?php echo esc_url( get_permalink( $download['product_id'] ) ); ?>"><?php echo esc_html( $download['product_name'] ); ?></a>
        <?php
    break;

...

This need a bit of update to include the switch_to_blog() and restore_current_blog() so add the 2 new lines:

...

switch ( $column_id ) {
    case 'download-product' : ?>
        <a href="<?php 
            
            if(isset($download['blog_id'])  &&  $download['blog_id']    >   0)
                switch_to_blog( $download['blog_id'] );
        
            echo esc_url( get_permalink( $download['product_id'] ) ); 
            
            if(isset($download['blog_id'])  &&  $download['blog_id']    >   0)
                restore_current_blog();    
        
        ?>"><?php echo esc_html( $download['product_name'] ); ?></a>
        <?php
    break;

...

Once code updated, the Product name should link to correct url, to shop where was native created.