тиньков эквайригн тиньков

с корзины сделать ссылку на tinkoff_form.php
в админке тинькова прописать tinkoff.php

require_once $_SERVER["DOCUMENT_ROOT"]."/wp-load.php";


// $ord_id = $order->get_items();
// echo '#'.$order_id;

//print_r($_SESSION);
$f = WC()->cart->total;
//$items = WC()->cart->get_cart();
//echo apply_filters( 'woocommerce_cart_totals_fee_html', $cart_totals_fee_html, $fee );
$cart_data = WC()->session->get('cart');

// echo '<pre>';
// print_r($cart_data);
// echo '</pre>';

//SELECT * FROM `wp_woocommerce_sessions` WHERE `session_value` LIKE '%bd0ee4a96ad3e5b8a48f00cb4e3a5865%' key
//$cart_data[array_keys($cart_data)[0]]['key']
global $wpdb;
if(!empty($cart_data[array_keys($cart_data)[0]]['key'])){
$fivesdrafts = $wpdb->get_results( "SELECT * FROM `wp_woocommerce_sessions` WHERE `session_value` LIKE '%".$cart_data[array_keys($cart_data)[0]]['key']."%' ORDER BY `wp_woocommerce_sessions`.`session_id` ASC" );
foreach ( $fivesdrafts as $fivesdraft ) {
$re = unserialize($fivesdraft->session_value);
}
}

//echo "SELECT * FROM `wp_woocommerce_sessions` WHERE `session_value` LIKE '%".$cart_data[array_keys($cart_data)[0]]['key']."%' ORDER BY `wp_woocommerce_sessions`.`session_id` ASC<br>";
// foreach ($re as $key => $value) {
// $rew = unserialize($value);

// echo $key.'###<pre>';
// print_r($rew);
// echo '</pre>';
// }
//$oo = $order->get_id();

$user_info = unserialize($re['customer']);
$user_cart = unserialize($re['guest_info']);
$cart_det = unserialize($re['cart']);
$cart_totals = unserialize($re['cart_totals']);//cart_totals

//$e = WC()->get_billing_phone( 'view' );


// echo '<pre>';
// print_r($user_cart);
// print_r($user_info);
// echo '</pre>';
if(empty($user_cart['billing_phone']) && !empty($user_info['phone'])){
// фикс для авторизованных
$user_cart['billing_company'] = $user_info['company'];
$user_cart['billing_email'] = $user_info['email'];
$user_cart['billing_phone'] = $user_info['phone'];
$user_cart['billing_address_1'] = $user_info['shipping_address'];
$user_cart['billing_address_2'] = $user_info['shipping_address_2'];
$user_cart['billing_city'] = $user_info['shipping_city'];
$user_cart['billing_state'] = $user_info['shipping_state'];
$user_cart['billing_postcode'] = $user_info['shipping_postcode'];
$user_cart['billing_country'] = $user_info['country'];

}

//echo 'order'.$_COOKIE["order"];

if(!empty($_COOKIE["order"])){
//echo 'нет номра';
$order2 = wc_get_order($_COOKIE["order"] ); //2440.00 $order2->total
if($order2->total!=$cart_totals['subtotal']){
//пересчитать заказ
$order2->remove_order_items( 'line_item' );
foreach ($cart_det as $key => $value) {
unset($args);
if(is_array($value['variation'])){
$args = array(
'variation' => array( 'attribute_pa_size' => $value['variation']['attribute_pa_size']),
);
}
$order2->add_product( get_product( $value['product_id'] ), 1, $args );
}
}
}

if(empty($_COOKIE["order"]) ){ //empty($re['order_awaiting_payment']) &&
//echo 'нет номра';
//SELECT * FROM `f50832_ttw`.`wp_woocommerce_order_itemmeta` WHERE (CONVERT(`meta_id` USING utf8) LIKE '%66445%' OR CONVERT(`order_item_id` USING utf8) LIKE '%66445%' OR CONVERT(`meta_key` USING utf8) LIKE '%66445%' OR CONVERT(`meta_value` USING utf8) LIKE '%66445%')

// $fivesdrafts = $wpdb->get_results( "SELECT * FROM `wp_wacv_abandoned_cart_record` WHERE `id` = '".$re['wacv_cart_record_id']."'" );
// foreach ( $fivesdrafts as $fivesdraft ) {
// //$re = unserialize($fivesdraft->session_value);
// $re['order_awaiting_payment'] = $fivesdraft->recovered_cart;
// }
if(empty($user_cart['billing_phone'])){
if(!empty($_COOKIE["phone"])){
$user_cart['billing_phone'] = $_COOKIE["phone"];
}
}
if(!empty($user_cart['billing_phone'])){
$order = wc_create_order();
$address = array(
'first_name' => $user_cart['billing_company'],
'last_name' => '',
'company' => '',
'email' => $user_cart['billing_email'],
'phone' => $user_cart['billing_phone'],
'address_1' => $user_cart['billing_address_1'],
'address_2' => $user_cart['billing_address_2'],
'city' => $user_cart['billing_city'],
'state' => $user_cart['billing_state'],
'postcode' => $user_cart['billing_postcode'],
'country' => $user_cart['billing_country']
);
foreach ($cart_det as $key => $value) {
unset($args);
if(is_array($value['variation'])){
$args = array(
'variation' => array( 'attribute_pa_size' => $value['variation']['attribute_pa_size']),
);
}
$order->add_product( get_product( $value['product_id'] ), 1, $args );
}
$order->set_address( $address, 'billing' );
$order->set_address( $address, 'shipping' );
$item = new WC_Order_Item_Shipping();
$item->set_method_title( "Доставка" ); // название
$item->set_method_id( "flat_rate:14" ); // указываем ID существующего способа доставки
$item->set_total( 450 ); // стоимость доставки (необязательно)
$order->add_item( $item );
$order->calculate_totals();
$order->update_status( 'pending payment' );
$order->add_order_note( 'Заказ создан' );
$re['order_awaiting_payment'] = $order->id;
//setcookie("order", $order->id, time()+3600);
setcookie("order", $order->id, time()+3600, '/','.'.$_SERVER['HTTP_HOST']);
header("Refresh: 0");
//sleep(1);
//DELETE FROM `wp_woocommerce_order_items` WHERE `wp_woocommerce_order_items`.`order_item_id` = 9093
}else{
// if(empty($_COOKIE["phone_err"])){
// setcookie("phone_err", 1, time()+3600, '/','.'.$_SERVER['HTTP_HOST']);
// header("Refresh: 0");
// }
//header("Refresh: 0");
//echo '<p>Вы не указали номер телефона! Вернитесь к оформлению заказа.</p><style>.tinkoffPayRow{display:none}</style>';
}
}

if(!empty($_COOKIE["order"])){
$re['order_awaiting_payment'] = $_COOKIE["order"];
}

//if($user_info['phone'] != $user_cart['phone']){}
//$user_info = $user_cart;
$user_info['first_name'] = $user_cart['billing_company'];
$user_info['last_name'] = '';
$user_info['email'] = $user_cart['billing_email'];
$user_info['phone'] = $user_cart['billing_phone'];


//$user_info['phone'] = '+799923455665';

//$total = str_replace(".", "", $f);
//$total = $f;
$total = number_format($f, 0, '.', '');

?>
<script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
<script src="https://securepay.tinkoff.ru/html/payForm/js/tinkoff_v2.js"></script>
<script>
$(document).ready(function(){
$('#total').val(<? echo $total; ?>);

var value = JSON.stringify({
"Email": '<? echo $user_info['email']; ?>',
"Phone": '<? echo $user_info['phone']; ?>',
"EmailCompany": '<? echo $user_info['email']; ?>',
"Taxation": "patent",
"Items": [
{
"Name": '<? echo $user_info['first_name'].' '.$user_info['last_name']; ?>',
"Price": '<? echo $total; ?>00',
"Quantity": 1.00,
"Amount": '<? echo $total; ?>00',
"PaymentMethod": "full_prepayment",
"PaymentObject": "service",
"Tax": "none"
}
]
});
$('#receipt').val(value);
console.log(value);
$("#frm1").submit();
});
</script>
<?
// тест 1680446950739DEMO
// боевой 1680446950739
?>
<form name="TinkoffPayForm" onsubmit="pay(this); return false;" id="frm1" style="display: none">
<input class="tinkoffPayRow" type="hidden" name="terminalkey" value="1680446950739">
<input class="tinkoffPayRow" type="hidden" name="frame" value="false">
<input class="tinkoffPayRow" type="hidden" name="language" value="ru">
<input class="tinkoffPayRow" type="hidden" value="<? echo $total; ?>" name="amount">
<input class="tinkoffPayRow" type="hidden" value="<? echo $re['order_awaiting_payment']; ?>" name="order">
<input class="tinkoffPayRow" type="hidden" value="Оплата заказа в магазине time2win.ru" name="description">
<input class="tinkoffPayRow" type="hidden" value="<? echo $user_info['first_name'].' '.$user_info['last_name']; ?>" name="name">
<input class="tinkoffPayRow" type="hidden" value="<? echo $user_info['email']; ?>" name="email">
<input class="tinkoffPayRow" type="hidden" value="<? echo $user_info['phone']; ?>" name="phone">

<input class="tinkoffPayRow" type="hidden" name="receipt" id="receipt" value="">
<input class="tinkoffPayRow" type="submit" value="Оплатить онлайн картой">
</form>

 


Сделать заказ

| необходим для связи с вами
В кротчайшие сроки я свяжусь с вами.

Также вы можетете связать со мной:
telegram: @ifwcom