• Resolved bahamen

    (@bahamen)


    Hello,
    I’m using 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

    (@bahamen)

    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

    (@woosms)

    Hi @bahamen,

    See the following 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

    (@woosms)

    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

    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.
Viewing 3 replies - 1 through 3 (of 3 total)

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