WPDM Premium Packages Shortcodes

Below, you’ll find a detailed guide on how to add the WPDM Premium Packages 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 Wpdm Premium Packages Plugin shortcodes not to show or not to work correctly.

Before starting, here is an overview of the Wpdm Premium Packages Plugin and the shortcodes it provides:

Plugin Icon
Premium Packages – Sell Digital Products Securely

"Premium Packages – Sell Digital Products Securely is a WordPress plugin that enables you to securely sell and manage digital products directly from your website with robust security features."

★★★☆✩ (4) Active Installs: 5000+ Tested with: 6.3.2 PHP Version: false
Included Shortcodes:
  • [wpdmpp_seller_dashboard]
  • [wpdmpp_earnings]
  • [wpdmpp_purchases]
  • [wpdmpp_guest_orders]
  • [wpdmpp_buynow]
  • [wpdmpp_withdraws]
  • [wpdmpp_cart]
  • [wpdmpp_pay_link]

[wpdmpp_seller_dashboard] Shortcode

The wpdm-premium-packages plugin shortcode, “wpdmpp_seller_dashboard”, generates a seller dashboard on WordPress. It uses the ob_start() function to turn on output buffering, registers a script for the dashboard, and includes a template for it.

Shortcode: [wpdmpp_seller_dashboard]

Examples and Usage

Basic example – The basic usage of the wpdmpp_seller_dashboard shortcode involves invoking the shortcode without any parameters/attributes. This will display the default seller dashboard.

[wpdmpp_seller_dashboard /]

Advanced examples

While the provided shortcode does not accept parameters in its current form, it could be modified to accept parameters for customization. Below is an example of how this could be achieved.

Let’s say, for instance, that we want to modify the shortcode to accept a ‘theme’ parameter, which would allow us to change the color scheme of the dashboard. We would first need to modify the shortcode function to accept and handle this parameter.


function sellerDashboard($atts){
    ob_start();
    wp_register_script("wpdmpp-seller-dashboard", WPDMPP_BASE_URL.'/assets/js/Chart.js');
    $theme = isset($atts['theme']) ? $atts['theme'] : 'default';
    include WPDM()->template->locate("wpdm-pp-seller-dashboard.php", WPDMPP_TPL_DIR, array('theme' => $theme));
    return ob_get_clean();
}

With the modified shortcode function, we can now use the ‘theme’ parameter in our shortcode. For example, to display the seller dashboard with a dark theme, we would use the following shortcode:

[wpdmpp_seller_dashboard theme="dark" /]

Please note that the actual implementation of themes in the seller dashboard would require additional coding not shown in this example.

PHP Function Code

In case you have difficulties debugging what causing issues with [wpdmpp_seller_dashboard] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( "wpdmpp_seller_dashboard",   array( $this, 'sellerDashboard') );

Shortcode PHP function:

function sellerDashboard(){
        ob_start();
        wp_register_script("wpdmpp-seller-dashboard", WPDMPP_BASE_URL.'/assets/js/Chart.js');
        include WPDM()->template->locate("wpdm-pp-seller-dashboard.php", WPDMPP_TPL_DIR);
        return ob_get_clean();
    }

Code file location:

wpdm-premium-packages/wpdm-premium-packages/includes/libs/ShortCodes.php

[wpdmpp_earnings] Shortcode

The ‘wpdmpp_earnings’ shortcode is part of the wpdm-premium-packages plugin. It initiates the ‘earnings’ function, retrieving and displaying the earnings data from the plugin’s template.

Shortcode: [wpdmpp_earnings]

Examples and Usage

Basic example – Display earnings using the ‘wpdmpp_earnings’ shortcode. This shortcode does not require any parameters and will display the earnings data as defined in the ‘wpdm-pp-earnings.php’ template file.

[wpdmpp_earnings /]

Advanced examples

Unfortunately, it seems that the ‘wpdmpp_earnings’ shortcode does not support any parameters based on the function provided. The function simply starts output buffering, includes the ‘wpdm-pp-earnings.php’ template file, and returns the buffered output. There are no parameters or attributes being passed to the function or the included template file.

This means that the output of this shortcode is solely dependent on the ‘wpdm-pp-earnings.php’ template file and cannot be modified through the use of shortcode parameters.

If you wish to modify the output of this shortcode, you would need to modify the ‘wpdm-pp-earnings.php’ template file directly, or create a new template file and change the file path in the ‘earnings’ function to point to your new template file.

For example, you could create a new template file called ‘my-earnings.php’ and modify the ‘earnings’ function like so:


function earnings()
{
    ob_start();
    include WPDM()->template->locate("my-earnings.php", WPDMPP_TPL_DIR);
    return ob_get_clean();
}

Now, the ‘wpdmpp_earnings’ shortcode will use your ‘my-earnings.php’ template file to generate its output.

PHP Function Code

In case you have difficulties debugging what causing issues with [wpdmpp_earnings] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'wpdmpp_earnings',           array( $this, 'earnings' ) );

Shortcode PHP function:

function earnings()
    {
        ob_start();
        include WPDM()->template->locate("wpdm-pp-earnings.php", WPDMPP_TPL_DIR);
        return ob_get_clean();
    }

Code file location:

wpdm-premium-packages/wpdm-premium-packages/includes/libs/ShortCodes.php

[wpdmpp_purchases] Shortcode

The wpdmpp_purchases shortcode is part of the WPDM Premium Packages plugin. It displays a user’s purchase history or a login form if they’re not logged in. This shortcode first checks if a user is logged in. If not, it displays a login form and a link to the guest order page if guest orders are enabled. If the user is logged in, it retrieves and displays all their orders.

Shortcode: [wpdmpp_purchases]

Examples and Usage

Basic example – This shortcode displays all purchases made by the current user on the WordPress site.

[wpdmpp_purchases /]

PHP Function Code

In case you have difficulties debugging what causing issues with [wpdmpp_purchases] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'wpdmpp_purchases',          array( $this, 'userPurchases' ) );

Shortcode PHP function:

function userPurchases()
    {
        global $current_user;

        $current_user = wp_get_current_user();
        $dashboard          = true;
        $wpdmpp_settings    = get_option('_wpdmpp_settings');

        ob_start();
        ?>
        <div class="w3eden">
        <?php
        if( ! is_user_logged_in() ) {

            // Show login/registration form. This is a Download Manager core template
            echo WPDM()->user->login->form();

            // If guest order is enabled then show guest order page link
            if( Session::get( 'last_order' ) && isset($wpdmpp_settings['guest_download']) && $wpdmpp_settings['guest_download'] == 1){
                include_once Template::locate("partials/guest_order_page_link.php", WPDMPP_TPL_DIR);
            }
        }else{

            // List all orders made by the user
            $order = new Order();
            $myorders = $order->GetOrders($current_user->ID);

            include_once wpdm_tpl_path('wpdm-pp-purchases.php', WPDMPP_TPL_DIR);
        }
        echo '</div>';

        $purchase_orders_html = ob_get_clean();

        return $purchase_orders_html;
    }

Code file location:

wpdm-premium-packages/wpdm-premium-packages/includes/libs/ShortCodes.php

[wpdmpp_guest_orders] Shortcode

The ‘wpdmpp_guest_orders’ shortcode is used to manage guest orders in the WPDM Premium Packages plugin. It checks if the guest download option is enabled in the settings. If enabled, it initiates a unique session for each guest order. If the current page is the guest order page, it sets the session.

Shortcode: [wpdmpp_guest_orders]

Examples and Usage

Basic example – Displays the guest orders using the wpdmpp_guest_orders shortcode.

[wpdmpp_guest_orders]

Advanced examples

Using the shortcode to display guest orders based on the session. It will display the guest orders if the session is initialized and the guest download option is enabled.


function guestOrders(){
    ob_start();
    global $post;

    if( get_wpdmpp_option('guest_download') != 1 )
        return 'Enable guest download from Premium Packages settings';

    if(is_object($post) && get_the_permalink() == wpdmpp_guest_order_page() && !Session::get('guest_order_init'))
        Session::set('guest_order_init', uniqid());

    include  wpdm_tpl_path('wpdm-pp-guest-orders.php', WPDMPP_TPL_DIR);
    return ob_get_clean();
}
add_shortcode( 'wpdmpp_guest_orders', 'guestOrders' );

Note: The above example is an advanced usage of the shortcode where we are defining the function and adding the shortcode in the same piece of code. This method can be used to display guest orders based on certain conditions. The conditions are defined in the function ‘guestOrders’ which is then added as a shortcode using the ‘add_shortcode’ function.

PHP Function Code

In case you have difficulties debugging what causing issues with [wpdmpp_guest_orders] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'wpdmpp_guest_orders',       array( $this, 'guestOrders' ) );

Shortcode PHP function:

function guestOrders(){
        ob_start();
        global $post;

        if( get_wpdmpp_option('guest_download') != 1 )
            return 'Enable guest download from Premium Packages settings';

        if(is_object($post) && get_the_permalink() == wpdmpp_guest_order_page() && !Session::get('guest_order_init'))
            Session::set('guest_order_init', uniqid());

        include  wpdm_tpl_path('wpdm-pp-guest-orders.php', WPDMPP_TPL_DIR);
        return ob_get_clean();
    }

Code file location:

wpdm-premium-packages/wpdm-premium-packages/includes/libs/ShortCodes.php

[wpdmpp_buynow] Shortcode

The ‘wpdmpp_buynow’ shortcode is part of the wpdm-premium-packages plugin. It generates a ‘Buy Now’ button for a product on your WordPress site. The shortcode requires a product ID to function. It also accepts a license parameter, which can adjust the product’s price. The output is a styled ‘Buy Now’ button which, when clicked, adds the product to the shopping cart.

Shortcode: [wpdmpp_buynow]

Parameters

Here is a list of all possible wpdmpp_buynow shortcode parameters and attributes:

  • id – The unique identifier for the product
  • license – The license type associated with the product

Examples and Usage

Basic example – Display a “Buy Now” button for a specific product using its ID.

[wpdmpp_buynow id=101 /]

Advanced examples

Display a “Buy Now” button for a specific product using its ID and specify a license for the product.

[wpdmpp_buynow id=101 license="Standard" /]

Display a “Buy Now” button for a specific product using its ID and specify a license and a custom title for the button.

[wpdmpp_buynow id=101 license="Premium" title="Purchase Now" /]

Note: Replace the id value with your actual product ID and the license value with your actual product license. The title attribute is optional and can be used to customize the text of the “Buy Now” button. If not provided, it will default to “Buy Now”.

PHP Function Code

In case you have difficulties debugging what causing issues with [wpdmpp_buynow] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'wpdmpp_buynow' ,            array( $this, 'buyNowHTML' ) );

Shortcode PHP function:

function buyNowHTML($params = array()){
        ob_start();
        if(!isset($params['id'])) {
            _e('Product ID is missing!', 'wpdm-premium-packages');
            return ob_get_clean();
        }
        $product_id = __::valueof($params, 'id');
        $license = __::valueof($params, 'license');
        $product = new Product($product_id);
        $price = $product->getLicensePrice($license);
        $params = array('title' => __('Buy Now', WPDMPP_TEXT_DOMAIN));
        echo "<div class='__wpdmpp_buy_now_zone_{$product_id}'>";
        include  wpdm_tpl_path('add-to-cart/buy-now.php', WPDMPP_TPL_DIR, WPDMPP_TPL_FALLBACK);
        echo "</div>";
        return ob_get_clean();
    }

Code file location:

wpdm-premium-packages/wpdm-premium-packages/includes/libs/ShortCodes.php

[wpdmpp_withdraws] Shortcode

The WPDM Premium Packages shortcode ‘wpdmpp_withdraws’ is designed to handle withdrawal requests. It retrieves current user’s requests and payout methods, and includes them in the user’s dashboard.

Shortcode: [wpdmpp_withdraws]

Examples and Usage

Basic example – The shortcode displays the withdrawal requests of the current user.

[wpdmpp_withdraws /]

PHP Function Code

In case you have difficulties debugging what causing issues with [wpdmpp_withdraws] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'wpdmpp_withdraws' ,      [ new Withdraws(), 'requests' ] );

Shortcode PHP function:

function requests() {
		ob_start();
		$requests = $this->getRequests( [ 'uid' => get_current_user_id() ] );
		$methods  = $this->getPayoutMethods();
		$accounts = get_user_meta( get_current_user_id(), '__wpdmpp_payment_account', true );
		include Template::locate( "dashboard/withdraws.php", WPDMPP_TPL_DIR );

		return ob_get_clean();
	}

Code file location:

wpdm-premium-packages/wpdm-premium-packages/includes/libs/ShortCodes.php

[wpdmpp_cart] Shortcode

The WPDM Premium Packages plugin shortcode, “wpdmpp_cart”, renders the shopping cart. It calculates discounts, fetches cart items, and displays total cost, tax, and coupon discounts.

Shortcode: [wpdmpp_cart]

Examples and Usage

Basic example – Display the default cart using the shortcode without any parameters.

[wpdmpp_cart /]

Advanced examples

Display the cart with specific settings from the options. This is useful when you want to override the global settings for a specific cart instance.

[wpdmpp_cart settings="_wpdmpp_settings" /]

Display the cart for guest checkout. This is useful when you want to allow guests to checkout without requiring them to create an account.

[wpdmpp_cart guest_checkout="1" /]

Display the cart with a specific cart ID. This is useful when you want to display a specific cart to a user.

[wpdmpp_cart cart_id="1234" /]

Please note that the parameters used in the advanced examples are dependent on the structure of your code and may not work if the code structure is different. Always test your shortcodes thoroughly to ensure they work as expected.

PHP Function Code

In case you have difficulties debugging what causing issues with [wpdmpp_cart] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( "wpdmpp_cart",       [ new Cart(), 'render' ] ); // function is in includes/libs/cart.php

Shortcode PHP function:

function render() {
		global $wpdb;
		wpdmpp_calculate_discount();
		$cart_data      = $this->getItems();
		$login_html     = "";
		$payment_html   = "";
		$settings       = get_option( '_wpdmpp_settings' );
		$guest_checkout = ( isset( $settings['guest_checkout'] ) && $settings['guest_checkout'] == 1 ) ? 1 : 0;
		$cart_id        = wpdmpp_cart_id();

		$cart_subtotal = $this->getCartPrice();

		$cart_coupon = $this->getCoupon();

		if ( ! __::valueof( $cart_coupon, 'code' ) ) {
			$cart_coupon = WPDMPP()->couponCodes->auto_coupon( $cart_subtotal );
		}

		$cart_total          = wpdmpp_get_cart_total();
		$cart_tax            = wpdmpp_get_cart_tax();
		$cart_total_with_tax = number_format( array_sum( [ $cart_total, $cart_tax ] ), 2, '.', '' );

		$cart_coupon_discount = isset( $cart_coupon['discount'] ) ? number_format( $cart_coupon['discount'], 2, '.', '' ) : 0.00;

		$Template = new Template();
		$Template->assign( 'guest_checkout', $guest_checkout );
		$Template->assign( 'cart_data', $cart_data );
		$Template->assign( 'cart_subtotal', $cart_subtotal );
		$Template->assign( 'cart_total', $cart_total );
		$Template->assign( 'cart_tax', $cart_tax );
		$Template->assign( 'cart_total_with_tax', $cart_total_with_tax );
		$Template->assign( 'cart_coupon', $cart_coupon );
		$Template->assign( 'settings', $settings );
		$Template->assign( 'cart_coupon_discount', $cart_coupon_discount );

		return $Template->fetch( 'checkout-cart/cart.php', WPDMPP_TPL_DIR, WPDMPP_TPL_FALLBACK );
	}

Code file location:

wpdm-premium-packages/wpdm-premium-packages/includes/libs/ShortCodes.php

[wpdmpp_pay_link] Shortcode

The wpdmpp_pay_link shortcode is utilized to generate a payment link within the WPDM Premium Packages plugin. This shortcode accepts parameters like ‘price’, ‘name’, ‘desc’, and ‘recurring’. It validates these parameters and creates a dynamic payment link. The link is displayed within a div element, styled with the CSS class provided in the ‘cssclass’ parameter. The link text defaults to ‘Pay Now’ unless a ‘label’ parameter is specified.

Shortcode: [wpdmpp_pay_link]

Parameters

Here is a list of all possible wpdmpp_pay_link shortcode parameters and attributes:

  • price – Sets the price for the product or service.
  • name – Specifies the name of the product or service.
  • desc – Provides a description for the product or service.
  • recurring – Determines whether the payment is recurring or one-time.
  • cssclass – Applies a specific CSS class to the payment link.
  • label – Sets the text for the payment link, default is ‘Pay Now’.

Examples and Usage

Basic example – A simple usage of the shortcode to display a pay link with a predefined price.

[wpdmpp_pay_link price="10" /]

Advanced examples

Using the shortcode to display a pay link with a predefined price, name, and description. The pay link will display the name and description of the product along with the price.

[wpdmpp_pay_link price="20" name="Premium Package" desc="This is a description for the premium package." /]

Using the shortcode to display a pay link with a predefined price, name, description, and recurring payment. The pay link will display the name and description of the product along with the price and set up a recurring payment.

[wpdmpp_pay_link price="30" name="Membership" desc="This is a description for the membership." recurring="1" /]

Using the shortcode to display a pay link with a predefined price, name, description, recurring payment, and custom CSS class. The pay link will display the name and description of the product along with the price, set up a recurring payment, and will have a custom CSS class applied to it.

[wpdmpp_pay_link price="40" name="Special Package" desc="This is a description for the special package." recurring="1" cssclass="custom-class" /]

Using the shortcode to display a pay link with a predefined price, name, description, recurring payment, custom CSS class, and custom label. The pay link will display the name and description of the product along with the price, set up a recurring payment, will have a custom CSS class applied to it, and the button will have a custom label.

[wpdmpp_pay_link price="50" name="Exclusive Package" desc="This is a description for the exclusive package." recurring="1" cssclass="custom-class" label="Buy Now" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [wpdmpp_pay_link] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( "wpdmpp_pay_link",      [ $this, 'payLink' ] );

Shortcode PHP function:

function payLink($params = [])
    {
        if(!(double)__::valueof($params, 'price')) return '';
        ob_start();
        $args = [ 'addtocart' =>  'dynamic', 'price' => (double)__::valueof($params, 'price')];
        if(__::valueof($params, 'name') !== '') $args['name'] = __::valueof($params, 'name', ['validate' => 'txt']);
        if(__::valueof($params, 'desc') !== '') $args['desc'] = __::valueof($params, 'desc', ['validate' => 'txt']);
        if(isset($params['recurring'])) $args['recurring'] = __::valueof($params, 'recurring', ['validate' => 'int']);
        ?>
        <div class="w3eden wpdmpp-pay-link"><a href="<?= add_query_arg($args, home_url('/?')); ?>" class="<?= __::valueof($params, 'cssclass', ['validate' => 'txt']); ?>"><?= __::valueof($params, 'label', 'Pay Now') ?></a></div>
        <?php
        return ob_get_clean();
    }

Code file location:

wpdm-premium-packages/wpdm-premium-packages/includes/libs/ShortCodes.php

Conclusion

Now that you’ve learned how to embed the Wpdm Premium Packages 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.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *