KD
Size: a a a
KD
И
И
KD
И
MD
И
KD
MD
И
<script type="text/javascript">
jQuery(document).ready(function () {
var present2 = jQuery("#present2").val();
jQuery.ajax({
type: "POST",
url: "/wp-admin/admin-ajax.php",
data: {
action : "ajax_present",
"present2" : present2
},
success: function(data){
console.log(data)
}
});
});
</script>
```
functions.php
```
add_action( 'wp_ajax_ajax_present', 'ajax_form' );
add_action( 'wp_ajax_nopriv_ajax_present', 'ajax_form' );
function ajax_form(){
add_action( 'woocommerce_email_order_details', 'display_applied_present', 10, 4 );
function display_applied_present( $order, $sent_to_admin, $plain_text, $email ) {
$present_code = $_POST['present2'];
echo '+Подарок' .$present_code;
};
}
И
MD
MD
MD
И
MD
MD
MD
function add_meta ( $order_id ) {
if ( empty( $_POST['krya'] ) ) {
return;
}
$order = new \WC_Order( $order_id );
$order->update_meta_data( 'your-custom-field-name', $_POST['krya'] );
}
MD
MD