Title: Custom variables
Last modified: February 19, 2020

---

# Custom variables

 *  Resolved [bahamen](https://wordpress.org/support/users/bahamen/)
 * (@bahamen)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/custom-variables-8/)
 * Hello,
    I’m using [https://docs.wpwebelite.com/woocommerce-pdf-vouchers/](https://docs.wpwebelite.com/woocommerce-pdf-vouchers/)
   for generation of redeeemable voucher codes.
 * These codes are stored in wp_postsmeta and they contain ordernumber of woocommerce
   order, but its stored in metakey_value not in post_id.
 * this is how I can get to the values in SQL:
    SELECT meta_value FROM `wp_postmeta`
   WHERE meta_key =”_woo_vou_purchased_codes” and post_id = 10126 SELECT DATE_FORMAT(
   meta_value, ‘%e.%m. %Y’) FROM `wp_postmeta` WHERE meta_key =”_woo_vou_exp_date”
   and post_id = 10126
 * the order_id is 10125 and is linked in another metakey_value: _woo_vou_order_id
 * Is there a way to get <voucher_code> and <voucher_expiration> to WooSMS?

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Thread Starter [bahamen](https://wordpress.org/support/users/bahamen/)
 * (@bahamen)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/custom-variables-8/#post-12456330)
 * S kolegou se mi podařilo dostat k SQL kódu pro select, který mi k vybranému číslu
   objednávky dotáhne veškeré informace, nicméně ani tak mi to nefunguje, je možné
   revidovat kód?
 * use BulkGate\Extensions;
 * !defined(‘ABSPATH’) && exit;
 * require_once(ABSPATH . ‘wp-admin/includes/plugin.php’);
 * /**
    * Check if WooSMS is installed */ if (is_plugin_active(‘woosms-sms-module-
   for-woocommerce/woosms-sms-module-for-woocommerce.php’)) { /** * Extend WooSMS*/
   add_action(“woosms_extends_variables”, function(Extensions\Hook\Variables $variables,
   Extensions\Database\IDatabase $database) { $result = $database->execute(‘SELECT
   main.post_id as cislo_ktere_mam, omg.post_id as cislo_ketere_nemam, omg.meta_id,
   omg.meta_key, omg.meta_value as vou_code, wtf.meta_value as vou_exp FROM wp_postmeta
   as main left join wp_postmeta as omg on omg.meta_value = main.post_id and omg.
   meta_key = “_woo_vou_purchased_codes”*/ left join wp_postmeta as wtf on wtf.meta_key
   = “_woo_vou_exp_date” WHERE main.post_id = “‘.( $database->escape($variables-
   >get(‘order_id’))).'” and main.meta_key = “_order_key” and wtf.post_id = omg.
   post_id’);
 *  if($result->getNumRows())
    { $row = $result->getRow(); $variables->set(‘vou_code’,
   $row->voucher_code); $variables->set(‘vou_exp’, $row->voucher_exp); }
 *  /** Now you can use in Customer or Admin SMS variable <test_variable> */
 *  }, 20, 2);
    } else { deactivate_plugins(plugin_basename(__FILE__)); }
 *  Plugin Author [BulkGate](https://wordpress.org/support/users/woosms/)
 * (@woosms)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/custom-variables-8/#post-12456335)
 * Hi [@bahamen](https://wordpress.org/support/users/bahamen/),
 * See the following [https://github.com/BulkGate/woosms-extensions](https://github.com/BulkGate/woosms-extensions)
 * Here is what you are looking for. If you need anything, feel free to ask any 
   questions.
 *  Plugin Author [BulkGate](https://wordpress.org/support/users/woosms/)
 * (@woosms)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/custom-variables-8/#post-12456385)
 * Dobrý den,
 * před odesláním zprávy se při načítání všech proměnných do zprávy provolává akce
   wordpressu “woosms_extends_variables”.
 * Je tedy možné vytvořit speciální plugin (to co jste poslal), který před odesláním
   vybere z databáze, co je potřeba, a pak je položku možné použít jako proměnnou.(
   Jen v náhledu to není vidět, pouze v odeslané SMS). Takový plugin se ukáže v 
   seznamu pluginů a je třeba jen aktivovat.
 * Příklady a ukázky naleznete zde: [https://github.com/BulkGate/woosms-extensions](https://github.com/BulkGate/woosms-extensions)
 * Pokud si nebudete vědět rady, napište na náš support a pomůžeme Vám tento plugin
   vyrobit pro Vaše potřeby.
    -  This reply was modified 6 years, 2 months ago by [BulkGate](https://wordpress.org/support/users/woosms/).

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Custom variables’ is closed to new replies.

 * ![](https://ps.w.org/woosms-sms-module-for-woocommerce/assets/icon.svg?rev=2620584)
 * [BulkGate SMS Plugin for WooCommerce](https://wordpress.org/plugins/woosms-sms-module-for-woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woosms-sms-module-for-woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woosms-sms-module-for-woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/woosms-sms-module-for-woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woosms-sms-module-for-woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woosms-sms-module-for-woocommerce/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [BulkGate](https://wordpress.org/support/users/woosms/)
 * Last activity: [6 years, 2 months ago](https://wordpress.org/support/topic/custom-variables-8/#post-12456385)
 * Status: resolved