MultivendorX
-
AuthorPosts
-
-
February 26, 2024 at 8:21 PM #217555l.ganParticipant
Hello, thanks for the great support!
Can you help me – I’m using a code that gets a list of all published coupons.
Coupon Code, Discount Amount, Description.HOW to display also: Vendor name, who is assigned the coupon?
If a vendor is not assigned to a coupon, the coupon should not be displayed in the shortcode.
If a vendor is assigned to a coupon, the coupon should be displayed in a shortcode and display the vendor’s name.Thank you for your help.
add_shortcode('ac', 'coupon_list' ); function coupon_list() { $coupon_posts = get_posts( array( 'posts_per_page' => -1, 'orderby' => 'name', 'order' => 'asc', 'post_type' => 'shop_coupon', 'post_status' => 'publish', ) ); $coupon_info = []; // Initializing foreach( $coupon_posts as $coupon_post) { $coupon_info[] = array( 'code' => $coupon_post->post_name, //'date_expires' => get_post_meta( $coupon_post->ID, 'date_expires', true ), //'expiry_date' => get_post_meta( $coupon_post->ID, 'expiry_date', true ), 'amount' => get_post_meta( $coupon_post->ID, 'coupon_amount', true ), //'discount_type' => get_post_meta( $coupon_post->ID,'discount_type', true), 'description' => $coupon_post->post_excerpt ); } // Display available coupon codes with additional information $output = ''; foreach( $coupon_info as $info ) { $output .= 'Code: ' . $info['code'] . ', ' . $info['expiry_date'] . $info['discount_type'] .', Amount: ' . $info['amount'] . ', Description: ' . $info['description'] . '<br>'; } return $output; // always use return in a shortcode }
CopyAttachments:
-
February 27, 2024 at 3:47 PM #217572Sangita Support SquadKeymaster
Hello @l.gan Our team has gone through your shared code and based on that we are providing you with the code to fetch the vendor object below.
$vendor_id = $coupon_post->post_author; $vendor = get_mvx_vendor($vendor_id);
CopyNow use the earlier shared code in your existing code accordingly to achieve your required flow.
Let us know if you need any further assistance from our end.
-
February 27, 2024 at 11:16 PM #217591l.ganParticipantThis reply has been marked as private.
-
February 28, 2024 at 3:53 PM #217621Sangita Support SquadKeymaster
We have already provided you earlier with the code to fetch the vendor data. Now to fetch the vendor name you need to use the below code –
$vendor->page_title
Copy -
February 28, 2024 at 6:33 PM #217639Sangita Support SquadKeymaster
Great to hear that. Let us know if you need any further assistance from our end.
Also, It would be really great if you can give us 5/5 review here: https://wordpress.org/support/plugin/dc-woocommerce-multi-vendor/reviews/#new-post
This would motivate the team further to do their job more efficiently. -
April 29, 2024 at 10:17 AM #219373Sangita Support SquadKeymaster
Hello There, Its been long and we have not heard back from you. We are closing this thread. If you need help or face issue on your end in future please do create a new support ticket.
-
-
AuthorPosts
The topic ‘How to get vendor name in coupon cycle’ is closed to new replies.