Advertisement
palsushobhan

store-link-on-order-thank-you-page

Jul 17th, 2024
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.31 KB | None | 0 0
  1. add_action('woocommerce_order_details_after_order_table', function($order_id) {
  2.     if( is_wc_endpoint_url( 'order-received' ) )  {
  3.         $order = wc_get_order($order_id);
  4.         $items = $order->get_items('line_item');
  5.         $vendors = array();
  6.         foreach ($items as $order_item_id => $item) {
  7.             $line_item = new WC_Order_Item_Product($item);
  8.             $product_id = $line_item->get_product_id();
  9.             $vendor_id = wcfm_get_vendor_id_by_post($product_id);
  10.             if ($vendor_id && !in_array($vendor_id, $vendors)) {
  11.                 $vendors[] = $vendor_id;
  12.             }
  13.         }
  14.         if(!empty($vendors)) {
  15.         ?><p class="return-to-shop"><?php
  16.             foreach($vendors as $vendor) {
  17.             ?>
  18.                 <a class="button wc-backward<?php echo esc_attr( wc_wp_theme_get_element_class_name( 'button' ) ? ' ' . wc_wp_theme_get_element_class_name( 'button' ) : '' ); ?>" href="<?php echo esc_url( apply_filters( 'wcfm_return_to_store_redirect', wcfmmp_get_store_url($vendor) ) ); ?>">
  19.                     <?php
  20.                         echo esc_html( __( 'Return to ', 'woocommerce' ) . wcfm_get_vendor_store_name($vendor) . __(' Store') );
  21.                     ?>
  22.                 </a>
  23.             <?php      
  24.             }
  25.         ?></p><?php
  26.         }
  27.     }
  28. }, 1);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement