/*
 Theme Name:    Electro Child
 Theme URI:     https://themeforest.net/item/electro-electronics-store-woocommerce-theme/15720624
 Description:   This is the child theme of Electro
 Author:        MadrasThemes
 Author URI:    https://madrasthemes.com/
 Template:      electro
 Version:       3.6.4
 License:       GNU General Public License v2 or later
 License URI:   http://www.gnu.org/licenses/gpl-2.0.html
 Tags:          light, dark, two-columns, right-sidebar, responsive-layout
 Text Domain:   electro-child
*/
/**
 * Add LINE + Call buttons on single product page (WooCommerce).
 * Update $line_id and $phone to your own.
 */
add_action('woocommerce_single_product_summary', 'ct_add_line_call_buttons', 35);
function ct_add_line_call_buttons() {

    $line_id = 'YOUR_LINE_ID';     // <- ใส่ Line ID (เช่น chonnatee หรือ @chonnatee)
    $phone   = '0812345678';       // <- ใส่เบอร์โทร (ตัวเลขเท่านั้น)

    // ลิงก์ LINE: ถ้าเป็น Official Account มักใช้รูปแบบนี้
    $line_url = 'https://line.me/R/ti/p/~' . ltrim($line_id, '@');

    // ถ้าคุณใช้ OA แบบมี @ และต้องการลิงก์ add friend ใช้รูปแบบนี้แทน (เลือกอย่างใดอย่างหนึ่ง)
    // $line_url = 'https://line.me/R/ti/p/' . rawurlencode($line_id);

    echo '<div class="ct-contact-buttons" style="margin-top:12px; display:flex; gap:10px; flex-wrap:wrap;">';
    echo '<a class="button alt" href="'. esc_url($line_url) .'" target="_blank" rel="noopener" style="text-decoration:none;">สอบถามทาง LINE</a>';
    echo '<a class="button" href="tel:' . esc_attr($phone) . '" style="text-decoration:none;">โทร ' . esc_html($phone) . '</a>';
    echo '</div>';
}
