Below, you’ll find a detailed guide on how to add the Wc Multivendor Membership Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Wc Multivendor Membership Plugin shortcodes not to show or not to work correctly.
Before starting, here is an overview of the Wc Multivendor Membership Plugin and the shortcodes it provides:
"WCFM Membership – WooCommerce Memberships for Multivendor Marketplace is a powerful plugin designed to manage and control memberships in your WooCommerce multi-vendor marketplace. It offers robust features for ultimate control."
- [wcfm_vendor_membership]
- [wcfm_vendor_registration]
- [wcfmvm_subscribe]
Wc Multivendor Membership [wcfm_vendor_membership] Shortcode
The WCFM Vendor Membership shortcode is a powerful tool in the wc-multivendor-membership plugin. It allows you to display the vendor membership details on any page. It retrieves global WCFM data and loads the ‘vendor-membership’ class. The shortcode then returns the output of the ‘WCFM_Vendor_Membership_Shortcode’ function.
Shortcode: [wcfm_vendor_membership]
Examples and Usage
Basic example – Display the vendor membership form on any page or post using the ‘wcfm_vendor_membership’ shortcode.
[wcfm_vendor_membership /]
PHP Function Code
In case you have difficulties debugging what causing issues with [wcfm_vendor_membership]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode('wcfm_vendor_membership', array(&$this, 'wcfm_vendor_membership'));
Shortcode PHP function:
function wcfm_vendor_membership($attr) {
global $WCFM;
$this->load_class('vendor-membership');
return $this->shortcode_wrapper(array('WCFM_Vendor_Membership_Shortcode', 'output'));
}
Code file location:
wc-multivendor-membership/wc-multivendor-membership/core/class-wcfmvm-shortcode.php
Wc Multivendor Membership [wcfm_vendor_registration] Shortcode
The WCFM Vendor Registration shortcode is a functional code snippet in the WC-Multivendor-Membership plugin. It enables the registration of new vendors on your WooCommerce site. In the PHP code, the ‘wcfm_vendor_registration’ function is defined. It calls the global ‘WCFM’ class and loads the ‘vendor-registration’ class. The ‘shortcode_wrapper’ function then outputs the result.
Shortcode: [wcfm_vendor_registration]
Examples and Usage
Basic example – The basic usage of the ‘wcfm_vendor_registration’ shortcode without any additional parameters.
[wcfm_vendor_registration /]
PHP Function Code
In case you have difficulties debugging what causing issues with [wcfm_vendor_registration]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode('wcfm_vendor_registration', array(&$this, 'wcfm_vendor_registraion'));
Shortcode PHP function:
function wcfm_vendor_registraion($attr) {
global $WCFM;
$this->load_class('vendor-registration');
return $this->shortcode_wrapper(array('WCFM_Vendor_Registration_Shortcode', 'output'));
}
Code file location:
wc-multivendor-membership/wc-multivendor-membership/core/class-wcfmvm-shortcode.php
Wc Multivendor Membership [wcfmvm_subscribe] Shortcode
The wc-multivendor-membership plugin shortcode ‘wcfmvm_subscribe’ is used to display a “Subscribe Now” button. This button allows users to subscribe to a membership plan. The shortcode checks if the user is an admin, if the user is allowed membership, and if a membership ID is provided. If these conditions are met, it displays a button with a customizable label and style. It also verifies if the user is already subscribed to the plan and displays a “Your Plan” message if true.
Shortcode: [wcfmvm_subscribe]
Parameters
Here is a list of all possible wcfmvm_subscribe shortcode parameters and attributes:
id
– Identifier for the membership plan to subscribe.subscribe_now
– Customizes the text on the subscription button.label
– Another way to customize the button text.background
– Sets the background color of the subscribe button.color
– Changes the text color of the subscribe button.
Examples and Usage
Basic example – The shortcode is used to display a subscription button for a specific membership plan. The ID of the plan is passed as a parameter.
[wcfmvm_subscribe id=1 /]
Advanced examples
Customizing the subscription button by changing the label and colors. The ‘subscribe_now’ parameter is used to change the label of the button. The ‘background’ and ‘color’ parameters are used to change the background color and text color of the button respectively.
[wcfmvm_subscribe id=1 subscribe_now="Join Now" background="#000000" color="#ffffff" /]
Using the ‘label’ parameter as an alternative to ‘subscribe_now’ to change the button label. This example also shows how to use the shortcode without specifying the colors, in which case the default colors will be used.
[wcfmvm_subscribe id=1 label="Sign Up Now" /]
Note: The ‘id’ parameter is mandatory and should be the ID of a valid membership plan. The ‘subscribe_now’ or ‘label’ parameters are optional and can be used to change the label of the button. The ‘background’ and ‘color’ parameters are also optional and can be used to change the background color and text color of the button respectively.
PHP Function Code
In case you have difficulties debugging what causing issues with [wcfmvm_subscribe]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode('wcfmvm_subscribe', array(&$this, 'wcfmvm_subscribe'));
Shortcode PHP function:
function wcfmvm_subscribe( $attr ) {
global $WCFM, $WCFMvm;
if( is_admin() ) return;
if( !apply_filters( 'wcfm_is_pref_membership', true ) ) return;
if( current_user_can( 'administrator' ) ) {
ob_start();
_e( 'Kindly logout from Admin account to have "Subscribe Now" button.', 'wc-multivendor-membership' );
return ob_get_clean();
}
if( !wcfm_is_allowed_membership() ) return;
$membership_id = 0;
if ( isset( $attr['id'] ) && !empty( $attr['id'] ) ) { $membership_id = $attr['id']; }
if( !$membership_id ) return;
$current_plan = wcfm_get_membership();
if( $current_plan && ( $current_plan == $membership_id ) ) {
?>
<h4 class="wcfm_membership_your_plan_label"><?php esc_html_e( 'Your Plan', 'wc-multivendor-membership' ); ?></h4>
<?php
return;
}
$subscribe_now_label = __( "Subscribe Now", 'wc-multivendor-membership' );
if ( isset( $attr['subscribe_now'] ) && !empty( $attr['subscribe_now'] ) ) {
$subscribe_now_label = $attr['subscribe_now'];
} elseif ( isset( $attr['label'] ) && !empty( $attr['label'] ) ) {
$subscribe_now_label = $attr['label'];
} else {
$wcfm_membership_options = get_option( 'wcfm_membership_options', array() );
$membership_type_settings = array();
if( isset( $wcfm_membership_options['membership_type_settings'] ) ) $membership_type_settings = $wcfm_membership_options['membership_type_settings'];
$default_subscribe_button = isset( $membership_type_settings['subscribe_button_label'] ) ? $membership_type_settings['subscribe_button_label'] : __( "Subscribe Now", 'wc-multivendor-membership' );
$subscribe_now_label = get_post_meta( (int) $membership_id, 'subscribe_button_label', true );
if( !$subscribe_now_label ) $subscribe_now_label = $default_subscribe_button;
}
$background_color = $color = $style ='';
if ( isset( $attr['background'] ) && !empty( $attr['background'] ) ) { $background_color = $attr['background']; }
if( $background_color ) { $style .= 'background-color: ' . $background_color . ';'; }
if ( isset( $attr['color'] ) && !empty( $attr['color'] ) ) { $color = $attr['color']; }
if( $color ) { $style .= 'color: ' . $color . ';'; }
ob_start();
?>
<div class="wcfm_ele_wrapper wcfm_membership_subscribe_button_wrapper">
<input class="wcfm_membership_subscribe_button wcfm_submit_button button" type="button" data-membership="<?php echo esc_attr($membership_id); ?>" style="<?php echo esc_attr($style); ?>" value="<?php esc_html_e( $subscribe_now_label, 'wc-multivendor-membership' ); ?>">
</div>
<?php
return ob_get_clean();
}
Code file location:
wc-multivendor-membership/wc-multivendor-membership/core/class-wcfmvm-shortcode.php
Conclusion
Now that you’ve learned how to embed the Wc Multivendor Membership Plugin shortcodes, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.
Leave a Reply