Gift Up Gift Cards for WordPress and WooCommerce Shortcode

Below, you’ll find a detailed guide on how to add the Gift Up Gift Cards for WordPress and WooCommerce Shortcode to your WordPress website, including its parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Gift Up Gift Cards for WordPress and WooCommerce Plugin shortcode not to show or not to work correctly.

Before starting, here is an overview of the Gift Up Gift Cards for WordPress and WooCommerce Plugin and the shortcodes it provides:

Plugin Icon
Gift Up Gift Cards for WordPress and WooCommerce

"Gift Up Gift Cards for WordPress and WooCommerce is a versatile plugin that enables businesses to sell gift cards on their WordPress or WooCommerce websites effortlessly. The plugin simplifies the process of creating, selling, and managing digital gift cards."

★★★★☆ (211) Active Installs: 5000+ Tested with: 6.3.2 PHP Version: 5.6
Included Shortcodes:
  • [giftup]

Gift Up Gift Cards for WordPress and WooCommerce [giftup] Shortcode

The Gift Up! shortcode is a customizable tool that allows you to integrate the gift card selling platform on your website. It accepts various parameters like ‘domain’, ‘product’, ‘group’, ‘payment’, and ‘language’. It also allows for purchaser and recipient details. It can hide certain elements like artwork, groups, and ungrouped items, and can accept a custom value amount. If the company ID is valid, it generates a gift card purchase interface, otherwise, it prompts the site admin to connect the Gift Up! account.

Shortcode: [giftup]

Parameters

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

  • domain – sets the domain for the gift-up target
  • company – defines the company ID for the gift-up
  • product – sets the product ID to be displayed
  • group – determines the group ID for the gift-up
  • payment – sets the payment methods for the gift-up
  • language – determines the language for the gift-up
  • purchasername – sets the name of the purchaser
  • purchaseremail – defines the purchaser’s email address
  • recipientname – sets the name of the gift recipient
  • recipientemail – defines the email of the gift recipient
  • whofor – determines who the gift is for
  • step – sets the step for the gift-up process
  • promocode – defines the promo code for the gift-up
  • hideartwork – hides the artwork for the gift-up
  • hidegroups – hides the groups for the gift-up
  • hideungroupeditems – hides ungrouped items for the gift-up
  • hidecustomvalue – hides the custom value for the gift-up
  • customvalueamount – sets the custom value amount for the gift-up

Examples and Usage

Basic example – Displaying a gift card for a specific company

[giftup company="xyz123"]

Advanced examples

Displaying a gift card for a specific company and product, with the purchaser’s name and email pre-filled

[giftup company="xyz123" product="abc123" purchasername="John Doe" purchaseremail="john.doe@example.com"]

Displaying a gift card for a specific company and product, with the purchaser’s and recipient’s details pre-filled, and a specific promo code applied

[giftup company="xyz123" product="abc123" purchasername="John Doe" purchaseremail="john.doe@example.com" recipientname="Jane Doe" recipientemail="jane.doe@example.com" promocode="PROMO123"]

Displaying a gift card for a specific company and group, with artwork and ungrouped items hidden

[giftup company="xyz123" group="group123" hideartwork="true" hideungroupeditems="true"]

Displaying a gift card for a specific company, with a custom value amount and the custom value option hidden

[giftup company="xyz123" customvalueamount="50" hidecustomvalue="true"]

PHP Function Code

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

Shortcode line:

add_shortcode( 'giftup', 'giftup_shortcode' );

Shortcode PHP function:

function giftup_shortcode( $atts ) {
    $a = shortcode_atts( array(
        'domain' => '',
        'company' => '',
        'product' => '',
        'group' => '',
        'payment' => '',
        'language' => '',
        'purchasername' => '',
        'purchaseremail' => '',
        'recipientname' => '',
        'recipientemail' => '',
        'whofor' => '',
        'step' => '',
        'promocode' => '',
        'hideartwork' => '',
        'hidegroups' => '',
        'hideungroupeditems' => '',
        'hidecustomvalue' => '',
        'customvalueamount' => ''
    ), $atts );
    
    $companyId = sanitize_text_field( $a['company'] );

    // Quotation sanitization
    $companyId = str_replace( "“", "", $companyId );
    $companyId = str_replace( "”", "", $companyId );
    $companyId = str_replace( "'", "", $companyId );
    $companyId = str_replace( "„", "", $companyId );
    $companyId = str_replace( "‘", "", $companyId );
    $companyId = str_replace( "’", "", $companyId );
    $companyId = str_replace( "‚", "", $companyId );

    if ( strlen($companyId) != 36 ) {
        $companyId = trim( giftup_options::get_company_id() );
    }

    if ( strlen($companyId) == 36 ) {
        ob_start();
        
        ?><div class="gift-up-target" 
            data-site-id="<?php echo $companyId ?>" 
            data-domain="<?php echo $a['domain'] ?>"
            data-product-id="<?php echo $a['product'] ?>"
            data-group-id="<?php echo $a['group'] ?>"
            data-payment-methods="<?php echo $a['payment'] ?>"
            data-language="<?php echo $a['language'] ?>"
            data-purchaser-name="<?php echo $a['purchasername'] ?>"
            data-purchaser-email="<?php echo $a['purchaseremail'] ?>"
            data-recipient-name="<?php echo $a['recipientname'] ?>"
            data-recipient-email="<?php echo $a['recipientemail'] ?>"
            data-step="<?php echo $a['step'] ?>"
            data-who-for="<?php echo $a['whofor'] ?>"
            data-promo-code="<?php echo $a['promocode'] ?>"
            data-hide-artwork="<?php echo $a['hideartwork'] ?>"
            data-hide-groups="<?php echo $a['hidegroups'] ?>"
            data-hide-ungrouped-items="<?php echo $a['hideungroupeditems'] ?>"
            data-hide-custom-value="<?php echo $a['hidecustomvalue'] ?>"
            data-custom-value-amount="<?php echo $a['customvalueamount'] ?>"
            data-platform="Wordpress"
        ></div>
        <script type="text/javascript">
        (function (g, i, f, t, u, p, s) {
            g[u] = g[u] || function() { (g[u].q = g[u].q || []).push(arguments) };
            p = i.createElement(f);
            p.async = 1;
            p.src = t;
            s = i.getElementsByTagName(f)[0];
            s.parentNode.insertBefore(p, s);
        })(window, document, 'script', 'https://cdn.giftup.app/dist/gift-up.js', 'giftup');
        </script><?php
        
        return ob_get_clean();
    }
    
    return "Notice to site admin: Please connect your Gift Up! account to WordPress in Settings / Gift Up!";
}

Code file location:

gift-up/gift-up/giftup.php

Conclusion

Now that you’ve learned how to embed the Gift Up Gift Cards for WordPress and WooCommerce Plugin shortcode, 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 *