/**
Theme Name: Astra Child
Author: Brainstorm Force
Author URI: http://wpastra.com/about/
Description: Astra is the fastest, fully customizable & beautiful theme suitable for blogs, personal portfolios and business websites. It is very lightweight (less than 50KB on frontend) and offers unparalleled speed. Built with SEO in mind, Astra comes with schema.org code integrated so search engines will love your site. Astra offers plenty of sidebar options and widget areas giving you a full control for customizations. Furthermore, we have included special features and templates so feel free to choose any of your favorite page builder plugin to create pages flexibly. Some of the other features: # WooCommerce Ready # Responsive # Compatible with major plugins # Translation Ready # Extendible with premium addons # Regularly updated # Designed, Developed, Maintained & Supported by Brainstorm Force. Looking for a perfect base theme? Look no further. Astra is fast, fully customizable and beautiful theme!
Version: 1.0.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: astra-child
Template: astra
*/


add_action('woocommerce_thankyou', 'golena_qnb_redirect');

function golena_qnb_redirect($order_id) {
    $order = wc_get_order($order_id);
    $total = number_format($order->get_total(), 2, '.', '');
    $merchant_id = '027700000025346';
    $terminal_id = 'V3416279';
    $merchant_pass = '23945691';
    $success_url = $order->get_checkout_order_received_url();
    $fail_url    = wc_get_checkout_url();
    $currency = '949';
    $txn_type = 'Auth';
    $secure_type = '3DPay';
    $mbr_id        = '5';
    $installment   = '0';
    $rnd           = (string)microtime(true);

    $hash_str = $mbr_id . $order_id . $total . $success_url . $fail_url . $txn_type . $installment . $rnd . $merchant_pass;
    $hash     = base64_encode( sha1($hash_str, true) );

    echo '<form id="qnbpay" action="https://vpos.qnb.com.tr/Gateway/3DHost.aspx" method="post">
    ...
</form>
<script>document.getElementById("qnbpay").submit();</script>';
}
// Hesap simgesini her zaman my-account sayfasına yönlendir
add_filter('nav_menu_link_attributes', 'golenac_force_account_link', 10, 3);
function golenac_force_account_link($atts, $item, $args){
    
    // Menüdeki hesabım simgesi /my-account/ içeriyorsa zorla bu URL'ye yönlendir
    if ( isset($atts['href']) && strpos($atts['href'], '/my-account') !== false ) {
        $atts['href'] = site_url('/my-account/');
    }

    return $atts;
}

