Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action('woocommerce_order_details_after_order_table', function($order_id) {
- if( is_wc_endpoint_url( 'order-received' ) ) {
- $order = wc_get_order($order_id);
- $items = $order->get_items('line_item');
- $vendors = array();
- foreach ($items as $order_item_id => $item) {
- $line_item = new WC_Order_Item_Product($item);
- $product_id = $line_item->get_product_id();
- $vendor_id = wcfm_get_vendor_id_by_post($product_id);
- if ($vendor_id && !in_array($vendor_id, $vendors)) {
- $vendors[] = $vendor_id;
- }
- }
- if(!empty($vendors)) {
- ?><p class="return-to-shop"><?php
- foreach($vendors as $vendor) {
- ?>
- <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) ) ); ?>">
- <?php
- echo esc_html( __( 'Return to ', 'woocommerce' ) . wcfm_get_vendor_store_name($vendor) . __(' Store') );
- ?>
- </a>
- <?php
- }
- ?></p><?php
- }
- }
- }, 1);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement