Welcart e-Commerce Shortcodes

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

Before starting, here is an overview of the Welcart e-Commerce Plugin and the shortcodes it provides:

Plugin Icon
Welcart e-Commerce

"Welcart e-Commerce is a robust and customizable WordPress plugin. Designed to transform your website into a fully functional online store, this plugin makes setting up and managing your e-commerce business a breeze."

★★★★✩ (4) Active Installs: 20000+ Tested with: 6.3.2 PHP Version: 7.4
Included Shortcodes:
  • [company_name]
  • [zip_code]
  • [address1]
  • [address2]
  • [tel_number]
  • [fax_number]
  • [inquiry_mail]
  • [payment]
  • [payment_title]
  • [cod_fee]
  • [start_point]
  • [postage_privilege]
  • [shipping_charge]
  • [site_url]
  • [button_to_cart]
  • [direct_intoCart]

Welcart e-Commerce [company_name] Shortcode

The USC-e-Shop plugin shortcode ‘company_name’ retrieves the company’s name set in the plugin options. This shortcode uses the ‘sc_company_name’ function to return the company name, ensuring it’s properly formatted.

Shortcode: [company_name]

Examples and Usage

Basic example – The shortcode [company_name /] will return the company’s name defined in the plugin’s settings.

[company_name /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'company_name', array( &$usces, 'sc_company_name' ) );

Shortcode PHP function:

function sc_company_name() {
		return htmlspecialchars( $this->options['company_name'], ENT_COMPAT );
	}

Code file location:

usc-e-shop/usc-e-shop/includes/default_filters.php

Welcart e-Commerce [zip_code] Shortcode

The USC-e-shop plugin shortcode, ‘zip_code’, retrieves the zip code option from the plugin settings. It sanitizes the data ensuring it’s safe for display.

Shortcode: [zip_code]

Examples and Usage

Basic example – Utilizing the shortcode to display a zip code. This shortcode does not require any additional parameters, as it fetches the zip code from the plugin’s options.

[zip_code /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'zip_code', array( &$usces, 'sc_zip_code' ) );

Shortcode PHP function:

function sc_zip_code() {
		return htmlspecialchars( $this->options['zip_code'], ENT_COMPAT );
	}

Code file location:

usc-e-shop/usc-e-shop/includes/default_filters.php

Welcart e-Commerce [address1] Shortcode

The USC-e-Shop plugin shortcode ‘address1’ retrieves the ‘address1’ field from the plugin’s options. It converts special characters to HTML entities for safe output.

Shortcode: [address1]

Examples and Usage

Basic example – A straightforward usage of the ‘address1’ shortcode is to simply call it without any parameters. This will return the ‘address1’ option from the usces object options array.

[address1 /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'address1', array( &$usces, 'sc_address1' ) );

Shortcode PHP function:

function sc_address1() {
		return htmlspecialchars( $this->options['address1'], ENT_COMPAT );
	}

Code file location:

usc-e-shop/usc-e-shop/includes/default_filters.php

Welcart e-Commerce [address2] Shortcode

The ‘address2’ shortcode from the usc-e-shop plugin is used to retrieve and display the second line of the stored address in a safe manner. This shortcode calls the ‘sc_address2’ function, which returns the ‘address2’ option from the plugin’s settings. It utilizes the htmlspecialchars function to ensure the output is safe to display.

Shortcode: [address2]

Examples and Usage

Basic example – In its simplest form, the ‘address2’ shortcode allows you to display the ‘address2’ option from your USC-e-Shop settings.

[address2 /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'address2', array( &$usces, 'sc_address2' ) );

Shortcode PHP function:

function sc_address2() {
		return htmlspecialchars( $this->options['address2'], ENT_COMPAT );
	}

Code file location:

usc-e-shop/usc-e-shop/includes/default_filters.php

Welcart e-Commerce [tel_number] Shortcode

The USC-e-Shop plugin shortcode ‘tel_number’ retrieves and displays a saved telephone number. It uses PHP function htmlspecialchars to ensure safe output.

Shortcode: [tel_number]

Examples and Usage

Basic example – Displays the telephone number set in the e-shop plugin options.

[tel_number /]

Advanced examples:

Display the telephone number with a prefix and suffix text. The shortcode will return the telephone number enclosed within the prefix and suffix texts.

[tel_number prefix="Call us now: " suffix=" for the best deals!" /]

Display the telephone number with a custom CSS class. The shortcode will return the telephone number wrapped in a span with the specified class.

[tel_number class="custom-phone-class" /]

Please note that the above advanced examples assume that the ‘sc_tel_number’ function has been modified to accept and process the ‘prefix’, ‘suffix’, and ‘class’ attributes. The actual function provided does not support these attributes.

PHP Function Code

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

Shortcode line:

add_shortcode( 'tel_number', array( &$usces, 'sc_tel_number' ) );

Shortcode PHP function:

function sc_tel_number() {
		return htmlspecialchars( $this->options['tel_number'], ENT_COMPAT );
	}

Code file location:

usc-e-shop/usc-e-shop/includes/default_filters.php

Welcart e-Commerce [fax_number] Shortcode

The ‘fax_number’ shortcode from the usc-e-shop plugin is designed to return the fax number option. It utilizes the ‘htmlspecialchars’ function to ensure safe output.

Shortcode: [fax_number]

Examples and Usage

Basic example – The shortcode displays the fax number of the store as set in the plugin options.

[fax_number /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'fax_number', array( &$usces, 'sc_fax_number' ) );

Shortcode PHP function:

function sc_fax_number() {
		return htmlspecialchars( $this->options['fax_number'], ENT_COMPAT );
	}

Code file location:

usc-e-shop/usc-e-shop/includes/default_filters.php

Welcart e-Commerce [inquiry_mail] Shortcode

The USC-e-Shop shortcode ‘inquiry_mail’ retrieves the inquiry email from the plugin’s options. It sanitizes the email output to prevent harmful code execution.

Shortcode: [inquiry_mail]

Examples and Usage

Basic example – The basic usage of the ‘inquiry_mail’ shortcode is to display the inquiry mail option from the plugin settings. It does not require any additional parameters.

[inquiry_mail /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'inquiry_mail', array( &$usces, 'sc_inquiry_mail' ) );

Shortcode PHP function:

function sc_inquiry_mail() {
		return htmlspecialchars( $this->options['inquiry_mail'], ENT_COMPAT );
	}

Code file location:

usc-e-shop/usc-e-shop/includes/default_filters.php

Welcart e-Commerce [payment] Shortcode

The USC-e-shop plugin shortcode ‘payment’ generates a list of available payment methods. It fetches system options, sorts them, and displays each payment method’s name and explanation.

Shortcode: [payment]

Examples and Usage

Basic example – Show a list of available payment methods using the ‘payment’ shortcode.

[payment /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'payment', array( &$usces, 'sc_payment' ) );

Shortcode PHP function:

function sc_payment() {
		$payments = usces_get_system_option( 'usces_payment_method', 'sort' );
		$htm = "<ul>\n";
		foreach ( (array)$payments as $payment ) {
			$htm .= "<li>" . htmlspecialchars( $payment['name'], ENT_COMPAT ) . "<br />\n";
			$htm .= nl2br( htmlspecialchars( $payment['explanation'], ENT_COMPAT ) ) . "</li>\n";
		}
		$htm .= "</ul>\n";
		return $htm;
	}

Code file location:

usc-e-shop/usc-e-shop/includes/default_filters.php

Welcart e-Commerce [payment_title] Shortcode

The ‘payment_title’ shortcode is part of the usc-e-shop plugin. It generates a list of all payment methods available in the plugin’s options. The PHP function ‘sc_payment_title’ retrieves these methods, creating an unordered list (ul) with each payment method as a list item (li). It then returns this HTML to be displayed wherever the shortcode is used.

Shortcode: [payment_title]

Examples and Usage

Basic example – The shortcode ‘payment_title’ is used to display the title of the payment method on your e-shop.

[payment_title /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'payment_title', array( &$usces, 'sc_payment_title' ) );

Shortcode PHP function:

function sc_payment_title() {
		$payments = $this->options['payment_method'];
		$htm = "<ul>\n";
		foreach ( (array)$payments as $payment ) {
			$htm .= "<li>" . esc_html($payment['name']) . "</li>\n";
		}
		$htm .= "</ul>\n";
		return $htm;
	}

Code file location:

usc-e-shop/usc-e-shop/includes/default_filters.php

Welcart e-Commerce [cod_fee] Shortcode

The ‘cod_fee’ shortcode from the usc-e-shop plugin retrieves the cash on delivery fee from the plugin’s options. It formats this fee to a readable number.

Shortcode: [cod_fee]

Examples and Usage

Basic example – This shortcode allows you to display the cash on delivery fee on your website.

[cod_fee /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'cod_fee', array( &$usces, 'sc_cod_fee' ) );

Shortcode PHP function:

function sc_cod_fee() {
		return number_format($this->options['cod_fee']);
	}

Code file location:

usc-e-shop/usc-e-shop/includes/default_filters.php

Welcart e-Commerce [start_point] Shortcode

The USC e-Shop shortcode ‘start_point’ is a function that returns a formatted number. This number represents the starting point of a specific feature or operation in the e-Shop.

Shortcode: [start_point]

Examples and Usage

Basic Example – A straightforward way to use the ‘start_point’ shortcode is to simply add it into a post or page. This will display the starting point value as defined in your USC e-Shop plugin settings.

[start_point /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'start_point', array( &$usces, 'sc_start_point' ) );

Shortcode PHP function:

function sc_start_point() {
		return number_format($this->options['start_point']);
	}

Code file location:

usc-e-shop/usc-e-shop/includes/default_filters.php

Welcart e-Commerce [postage_privilege] Shortcode

The USC-e-shop plugin shortcode ‘postage_privilege’ is used to display the postage privilege amount, if it’s set in the options. It formats the value into a readable number.

Shortcode: [postage_privilege]

Examples and Usage

Basic example – Showcases the usage of the ‘postage_privilege’ shortcode without any additional parameters.

[postage_privilege /]

The ‘postage_privilege’ shortcode, as defined in the USC e-shop plugin, doesn’t accept any parameters. It simply returns the formatted value of the ‘postage_privilege’ option if it’s set in the plugin’s options.

Now let’s move on to an advanced example. Please note that the ‘postage_privilege’ shortcode, as it is, doesn’t accept parameters. However, for the sake of this example, let’s assume that the shortcode function has been modified to accept parameters.

PHP Function Code

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

Shortcode line:

add_shortcode( 'postage_privilege', array( &$usces, 'sc_postage_privilege' ) );

Shortcode PHP function:

function sc_postage_privilege() {
		if(empty($this->options['postage_privilege']))
			return;
		return number_format($this->options['postage_privilege']);
	}

Code file location:

usc-e-shop/usc-e-shop/includes/default_filters.php

Welcart e-Commerce [shipping_charge] Shortcode

The ‘shipping_charge’ shortcode from the USC-e-shop plugin calculates and displays the shipping charge range based on the customer’s country. It fetches the shipping charges applicable to the specified country, sorts them, and returns the minimum and maximum values.

Shortcode: [shipping_charge]

Examples and Usage

Basic Example – The basic usage of the ‘shipping_charge’ shortcode allows you to display the shipping charge based on the customer’s country. It doesn’t require any parameters because it uses the customer’s details from the cart.

[shipping_charge /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'shipping_charge', array( &$usces, 'sc_shipping_charge' ) );

Shortcode PHP function:

function sc_shipping_charge() {
		$entry = $this->cart->get_entry();
		$country = (isset($entry['delivery']['country']) && !empty($entry['delivery']['country'])) ? $entry['delivery']['country'] : $entry['customer']['country'];
		$arr = array();
		foreach ( (array)$this->options['shipping_charge'] as $charges ) {
			foreach ( (array)$charges[$country] as $value ) {
				$arr[] = $value;
			}
		}
		sort($arr);
		$min = $arr[0];
		rsort($arr);
		$max = $arr[0];
		if($min == $max){
			$res = number_format($min);
		}else{
			$res = number_format($min) . __(' - ', 'usces') . number_format($max);
		}
		return $res;
	}

Code file location:

usc-e-shop/usc-e-shop/includes/default_filters.php

Welcart e-Commerce [site_url] Shortcode

The USC-e-Shop plugin shortcode ‘site_url’ returns the home URL of the website. It utilizes the ‘get_option’ function in PHP to retrieve the ‘home’ option from the WordPress database.

Shortcode: [site_url]

Examples and Usage

Basic example – In this basic usage example, the ‘site_url’ shortcode is used without any parameters. This will simply return the website’s home URL as defined in the WordPress settings.

[site_url /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'site_url', array( &$usces, 'sc_site_url' ) );

Shortcode PHP function:

function sc_site_url() {
		return get_option('home');
	}

Code file location:

usc-e-shop/usc-e-shop/includes/default_filters.php

Welcart e-Commerce [button_to_cart] Shortcode

The ‘button_to_cart’ shortcode from usc-e-shop plugin is designed to add a ‘to the cart’ button on your eCommerce site. This shortcode fetches product details, checks stock status, and generates an HTML form that allows users to add the item to their cart directly.

Shortcode: [button_to_cart]

Parameters

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

  • item – Specifies the name of the item to be added in the cart.
  • sku – Defines the stock keeping unit of the item for inventory tracking.
  • value – Sets the text for the button leading to the cart.
  • force – Determines if the item is added directly to the cart (value 1) or not (value 0).
  • quant – If set to 1, it allows the user to specify the quantity of the item.
  • opt – Controls the display of item options. If set to 1, options are shown; if 2, they’re hidden.

Examples and Usage

Basic example – The following shortcode allows you to add a button to the shopping cart for a specific item in the e-shop. It only requires the item’s name as a parameter.

[button_to_cart item="Item Name" /]

Advanced examples

1. This shortcode includes the SKU of the item along with the item’s name. This is useful when you have multiple variants of the same item differentiated by their SKU.

[button_to_cart item="Item Name" sku="12345" /]

2. This shortcode includes a custom value for the button. Instead of the default “to the cart”, the button will display “Add to my cart”.

[button_to_cart item="Item Name" value="Add to my cart" /]

3. This shortcode forces the item to be added to the cart, regardless of its stock status. The ‘force’ parameter is set to 1, meaning true.

[button_to_cart item="Item Name" force=1 /]

4. With this shortcode, you can specify the quantity of the item to be added to the cart. The ‘quant’ parameter is set to 2.

[button_to_cart item="Item Name" quant=2 /]

5. This shortcode includes the ‘opt’ parameter set to 1, which allows the use of item options. This is useful when your item has additional options like size or color.

[button_to_cart item="Item Name" opt=1 /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'button_to_cart', array( &$usces, 'sc_button_to_cart' ) );

Shortcode PHP function:

function sc_button_to_cart($atts) {
		extract(shortcode_atts(array(
			'item' => '',
			'sku' => '',
			'value' => __('to the cart', 'usces'),
			'force' => 0,
			'quant' => 0,
			'opt' => 1,
		), $atts));


		$post_id  = $this->get_ID_byItemName( $item );
		$datas    = $this->get_skus( $post_id, 'code' );
		$zaikonum = ( isset( $datas[ $sku ]['stocknum'] ) ) ? $datas[ $sku ]['stocknum'] : null;
		$zaiko    = ( isset( $datas[ $sku ]['stock'] ) ) ? $datas[ $sku ]['stock'] : 2;
		$gptekiyo = ( isset( $datas[ $sku ]['gp'] ) ) ? $datas[ $sku ]['gp'] : null;
		$skuPrice = ( isset( $datas[ $sku ]['price'] ) ) ? $datas[ $sku ]['price'] : 0;
		$sku_enc  = urlencode( $sku );
		$options  = usces_get_opts($post_id, 'sort');
		$mats     = compact('item','sku','value','force','quant','post_id','datas','zaikonum','zaiko','gptekiyo','skuPrice','sku_enc');
		if( ! $this->is_item_zaiko( $post_id, $sku ) ){
			return '<div class="button_status">' . esc_html($this->zaiko_status[$zaiko]) . '</div>';
		}

		$html = "<form action=\"" . USCES_CART_URL . "\" method=\"post\">\n";
		$html .= "<input name=\"zaikonum[{$post_id}][{$sku_enc}]\" type=\"hidden\" id=\"zaikonum[{$post_id}][{$sku_enc}]\" value=\"" . esc_attr( $zaikonum ) . "\" />\n";
		$html .= "<input name=\"zaiko[{$post_id}][{$sku_enc}]\" type=\"hidden\" id=\"zaiko[{$post_id}][{$sku_enc}]\" value=\"" . esc_attr( $zaiko ) . "\" />\n";
		$html .= "<input name=\"gptekiyo[{$post_id}][{$sku_enc}]\" type=\"hidden\" id=\"gptekiyo[{$post_id}][{$sku_enc}]\" value=\"" . esc_attr( $gptekiyo ) . "\" />\n";
		$html .= "<input name=\"skuPrice[{$post_id}][{$sku_enc}]\" type=\"hidden\" id=\"skuPrice[{$post_id}][{$sku_enc}]\" value=\"" . esc_attr( $skuPrice ) . "\" />\n";
		if( 1 == $opt ){
			$html .= usces_item_option_fileds( $post_id, $sku, 1, 'return' );
		}elseif( 2 == $opt ){
			$html .= usces_item_option_fileds( $post_id, $sku, 0, 'return' );
		}
		if( $quant ){
			$quant_field = "<input name=\"quant[{$post_id}][" . $sku_enc . "]\" type=\"text\" id=\"quant[{$post_id}][" . $sku_enc . "]\" class=\"skuquantity\" value=\"\" onKeyDown=\"if (event.keyCode == 13) {return false;}\" />";
			$html .= apply_filters('usces_filter_sc_itemQuant', $quant_field, $mats);
		}
		$html .= "<input name=\"inCart[{$post_id}][{$sku_enc}]\" type=\"submit\" id=\"inCart[{$post_id}][{$sku_enc}]\" class=\"skubutton\" value=\"" . esc_attr( $value ) . "\" " . apply_filters('usces_filter_direct_intocart_button', NULL, $post_id, $sku, $force, $options) . " />";
		$html .= "<input name=\"usces_referer\" type=\"hidden\" value=\"" . esc_url($_SERVER['REQUEST_URI']) . "\" />\n";
		if( $force )
			$html .= "<input name=\"usces_force\" type=\"hidden\" value=\"incart\" />\n";
		$html = apply_filters('usces_filter_single_item_inform', $html);
		$html .= "</form>";
		$html .= '<div class="error_message">' . usces_singleitem_error_message($post_id, $sku, 'return') . '</div>'."\n";

		return $html;
	}

Code file location:

usc-e-shop/usc-e-shop/includes/default_filters.php

Welcart e-Commerce [direct_intoCart] Shortcode

The ‘direct_intoCart’ shortcode from the usc-e-shop plugin allows users to add specific items directly into their shopping cart. This function retrieves the item’s ID based on its name, then uses the usces_direct_intoCart function to add the item to the cart. If the item or SKU is blank, it returns an empty string.

Shortcode: [direct_intoCart]

Parameters

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

  • item – Name of the product you want to add to the cart
  • sku – Unique identifier of the product variant
  • value – Represents the quantity of the product
  • options – Additional options related to the product

Examples and Usage

Basic example – A shortcode that inserts a specific item into the cart by referencing its name and SKU.

[direct_intoCart item="item_name" sku="item_sku" /]

Advanced examples

Using the shortcode to insert a specific item into the cart by referencing its name and SKU, along with a specific value and options. The value and options parameters can be used to specify additional details about the item, such as quantity or color.

[direct_intoCart item="item_name" sku="item_sku" value="2" options="color:red" /]

Using the shortcode to insert a specific item into the cart by referencing its name and SKU, along with a specific value. The value parameter can be used to specify the quantity of the item to be added to the cart.

[direct_intoCart item="item_name" sku="item_sku" value="3" /]

Using the shortcode to insert a specific item into the cart by referencing its name and SKU, along with specific options. The options parameter can be used to specify additional details about the item, such as color or size.

[direct_intoCart item="item_name" sku="item_sku" options="color:blue,size:large" /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'direct_intoCart', 'sc_direct_intoCart' );

Shortcode PHP function:

function sc_direct_intoCart($atts) {
	global $usces;
	extract(shortcode_atts(array(
		'item' => '',
		'sku' => '',
		'value' => NULL,
		'options' => NULL,
	), $atts));

	if( WCUtils::is_blank($item) || WCUtils::is_blank($sku) ) return '';
	
	$post_id = $usces->get_ID_byItemName($item);
	
	return usces_direct_intoCart($post_id, $sku, true, $value, $options, 'return');
}

Code file location:

usc-e-shop/usc-e-shop/includes/default_filters.php

Conclusion

Now that you’ve learned how to embed the Welcart e-Commerce 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 *