Using Shortcode

  • Author
    Posts
  • #217346

    Ishmeal Bosoka
    Participant

    Hi
    I’m trying to use a custome shortcode
    example

    // Register the shortcode [wec_billing_name]
    add_shortcode(‘wec_billing_name’, function() {
    $object = get_current_order();
    if ($object && is_a($object, ‘WC_Order’)) {
    return esc_html($object->get_billing_first_name() . ‘ ‘ . $object->get_billing_last_name());
    }
    return ‘-‘;
    });

    But it only works or show the value when i create the order in the wordpress (woocommerce)admin edit page. If an order is made at the front end the shortcode return the dash(-).

    Any sample shortcode, code to display a billing first name and also a custom field(meta field) will help.

    I know you have this [wec_order_meta key=”] but i want a typical wordpress shortcode.

    Thank You

You must be logged in to see replies to this topic. Click here to login or register