$price ) {
$product_id = (int)$price_request['product_id'];
$comments = sanitize_textarea_field($_POST['p3dlite_comments'][$id]);
$weight = (float)$_POST['p3dlite_weight'][$id];
$quantity = (int)$_POST['p3dlite_quantity'][$id];
$length = (float)$_POST['p3dlite_length'][$id];
$width = (float)$_POST['p3dlite_width'][$id];
$height = (float)$_POST['p3dlite_height'][$id];
$price = (float)$price;
$update_array = array('admin_comment'=>$comments, 'price'=>$price, 'weight'=>$weight, 'quantity'=>$quantity, 'scale_x'=>$length, 'scale_y'=>$width, 'scale_z'=>$height);
// if ((float)$price>0) {
// $update_array['status']=1;
// }
$wpdb->update($wpdb->prefix.'p3dlite_price_requests', $update_array, array('id'=>$id));
wp_redirect( admin_url( 'admin.php?page=p3dlite_price_requests&action=edit&price_request='.(int)$_GET['price_request'] ) );
}
}
if ( isset($_POST['action']) && $_POST['action']=='update' && isset( $_POST['p3dlite_buynow'] ) && count( $_POST['p3dlite_buynow'] )>0 ) {
if ( ! isset( $_POST['p3d_price_requests_edit'] ) || ! wp_verify_nonce( $_POST['p3d_price_requests_edit'], 'update' ) ) {
print 'Sorry, your nonce did not verify.';
exit;
}
$is_bundle = false;
$body='';
foreach ( $_POST['p3dlite_buynow'] as $id=>$price ) {
$comments = sanitize_textarea_field($_POST['p3dlite_comments'][$id]);
$weight = (float)$_POST['p3dlite_weight'][$id];
$quantity = (int)$_POST['p3dlite_quantity'][$id];
$length = (float)$_POST['p3dlite_length'][$id];
$width = (float)$_POST['p3dlite_width'][$id];
$height = (float)$_POST['p3dlite_height'][$id];
$price = (float)$price;
$custom_attributes = '';
$message = '';
if ( count( $price_request ) ) {
$email=$price_request['email'];
if (strlen($email)==0) $email=$price_request['email_address'];
# $variation=json_decode($price_request['attributes'], true);
$filename=$price_request['model_file'];
# $variation['attribute_pa_p3dlite_model']=rawurlencode( $variation['attribute_pa_p3dlite_model'] );
if ( true ) {
//echo $product_url;
$price_request['price']=$price;
$current_templates = get_option( 'p3dlite_email_templates' );
$template_body = $current_templates['client_email_body'];
$template_subject = $current_templates['client_email_subject'];
$from = $current_templates['client_email_from'];
$upload_dir = wp_upload_dir();
$link = esc_url($upload_dir['baseurl'] ."/p3d/".rawurlencode($filename));
$subject=esc_html__( "Your model's price" , '3dprint-lite' );
$model_link = "".esc_html($filename)."";
$dimensions=$price_request['scale_x']." × ".$price_request['scale_y']." × ".$price_request['scale_z']." ".esc_html__('cm', '3dprint-lite')."
";
$replace_from = array('[quantity]', '[printer_name]', '[material_name]', '[coating_name]', '[infill]', '[model_file]', '[dimensions]', '[weight]', '[price]', '[price_total]', '[admin_comments]');
$replace_to = array ($quantity, $price_request['printer'], $price_request['material'],
(isset($price_request['coating']) ? $price_request['coating'] : ''), (isset($price_request['infill']) ? $price_request['infill'] : ''), $link, $dimensions, $weight,
p3dlite_format_price($price, $settings['currency'], $settings['currency_position']), p3dlite_format_price($price*$quantity, $settings['currency'], $settings['currency_position']), $comments);
$subject=str_ireplace($replace_from, $replace_to, $template_subject);
$body=str_ireplace($replace_from, $replace_to, $template_body);
do_action('p3dlite_send_quote', $message);
$headers = array();
$headers[] = "From: $from";
$headers[] = 'Content-Type: text/html; charset=UTF-8';
$wpdb->update($wpdb->prefix.'p3dlite_price_requests', array('status'=>1, 'admin_comment'=>$comments, 'price'=>$price, 'quantity'=>$quantity, 'weight'=>$weight, 'scale_x'=>$length, 'scale_y'=>$width, 'scale_z'=>$height), array('id'=>$id));
}
# else {
# echo '
' . esc_html__('Please set the price.' ,'3dprint-lite').'
' . esc_html__('Could not email the quote! Check if your wordpress site can send emails and consider installing Easy WP SMTP plugin.' ,'3dprint-lite').'