Okay
  Public Ticket #1637763
MySQL with WPDataTables
Closed

Comments

  • Josh Grieve started the conversation

    I'm trying to find a way for data to carry throughout the site after a "selection" is made from the table.

    For example:

    If a user searches the table on the front end, the result that appears needs to carry over to a different field (or a woocommerce custom field if possible). 

    I have the databases setup right now with fields Date, Location. Once a user finds the correct date and location the result needs to be included when the user is making a "checkout" through the shop.

    Is there a query or html tag to use for this??

  •  443
    Bogdan replied

    Hi Josh Grieve,
    Thank you for your purchase.

    Sorry but I did not quite understand what are you trying to achieve. Can you please describe me more or send me some example/screenshot so I can take a look and give you my suggestion.

    Best regards.

    Check out our new Support Help Center!

    Check out our newest product - Amelia - Enterprise-Level WordPress Appointment Booking Plugin - promo price for launch period!

    Kind Regards,
    Bogdan Radusinovic
    bogdan@touchmesoft.net

  • Josh Grieve replied

    Hi Bogdan,

    Here is the flow I'm looking for:

    -User searches the table for a specific term.

    -Once the result appears in the table from the search, that result needs to be passed to another field so that when a user makes a purchase, that result is included in a custom field.

  • Josh Grieve replied

    I'm thinking I may be able to do it using this code. Just not sure what the input name is for the search field?

    /**
     * Add engraving text to cart item.
     *
     * @param array $cart_item_data
     * @param int   $product_id
     * @param int   $variation_id
     *
     * @return array
     */
    function iconic_add_engraving_text_to_cart_item( $cart_item_data, $product_id, $variation_id ) {
    $engraving_text = filter_input( INPUT_POST, 'iconic-engraving' );

    if ( empty( $engraving_text ) ) {
    return $cart_item_data;
    }

    $cart_item_data['iconic-engraving'] = $engraving_text;

    return $cart_item_data;
    }

    add_filter( 'woocommerce_add_cart_item_data', 'iconic_add_engraving_text_to_cart_item', 10, 3 );

     * Display engraving text in the cart.
     *
     * @param array $item_data
     * @param array $cart_item
     *
     * @return array
     */
    function iconic_display_engraving_text_cart( $item_data, $cart_item ) {
        if ( empty( $cart_item['iconic-engraving'] ) ) {
            return $item_data;
        }
     
        $item_data[] = array(
            'key'     => __( 'Engraving', 'iconic' ),
            'value'   => wc_clean( $cart_item['iconic-engraving'] ),
            'display' => '',
        );
     
        return $item_data;
    }
     
    add_filter( 'woocommerce_get_item_data', 'iconic_display_engraving_text_cart', 10, 2 );

    /**
     * Add engraving text to order.
     *
     * @param WC_Order_Item_Product $item
     * @param string                $cart_item_key
     * @param array                 $values
     * @param WC_Order              $order
     */
    function iconic_add_engraving_text_to_order_items( $item, $cart_item_key, $values, $order ) {
    if ( empty( $values['iconic-engraving'] ) ) {
    return;
    }

    $item->add_meta_data( __( 'Engraving', 'iconic' ), $values['iconic-engraving'] );
    }

    add_action( 'woocommerce_checkout_create_order_line_item', 'iconic_add_engraving_text_to_order_items', 10, 4 );

  •  443
    Bogdan replied

    Hi Josh,

    As much as I would like to help you out with this one but unfortunately due to our support policy please note that customization questions like this one are not covered in the included support for the plugin. Included support covers help with bugs and general inquiries for the plugin features, but not writing custom code.

    As you're developing some custom solution if you need our assistance we can offer you our paid customization service.

    Best regards.

    Check out our new Support Help Center!

    Check out our newest product - Amelia - Enterprise-Level WordPress Appointment Booking Plugin - promo price for launch period!

    Kind Regards,
    Bogdan Radusinovic
    bogdan@touchmesoft.net