Ecommerce Shopify WordPress Discussion

A button inside an $out table created to fetch an uploaded file from a database is not working

The button is needed to open the files uploaded by customers via an admin account. All the code for the button was added into wp-functions.php and presented inside a table using $out. Below is a piece of code: function allOrders() { require get_template_directory() . '/bd.php'; if($_SESSION['auth'] != 1) { $where = 'WHERE userid = '.$_SESSION['auth']; } $query = "SELECT * FROM wp_orders $where ORDER BY id DESC"; $sql = mysqli_query($link, $query); if(!$sql) { echo mysqli_error($link); } $out = ''; while($res = mysqli_fetch_array($sql)) { foreach(json_decode($res['status'], true) as $key => $value) { $status_key = $key; $status_val = $value; } if($res['filetype'] == 'file') { if(end(explode('.',$res['file'])) != 'pdf' ? $ftype = 'doc' : $ftype = 'pdf'); } else { $ftype = $res['filetype']; } $out.= '<tr class="orders-table_td">'; $out.= '<td class="order_num '.$ftype.'">'.__('[:fr]Commande[:en]Order').' #'.$res['number'].'</td>'; $out.= '<td class="order_words">'.$res['cnt_word'].' '.__('[:fr]'.($res['filetype'] == 'file' ? 'mots' : 'minutes').'[:en]'.($res['filetype'] == 'file' ? 'words' : 'minutes').'').'</td>'; $out.= '<td class="order_cost">'.$res['cost'].' '.__('[:fr]euros[:en]EUR').'</td>'; $out.= '<td class="order_status"><span class="'.$status_key .'">'.$status_val.'</span></td>'; if($status_key == 'o-draft' AND $_SESSION['auth'] != 1 ) { $out.= '<td class="order_btn"><span class="order_publish" id="order_publish" data-order="'.$res['id'].'">'.__('[:fr]Commander[:en]Place an order').'</span>'.($_SESSION['auth'] == 1 ? '<span class="delOrder" data-id="'.$res['id'].'" data-file="'.$res['file'].'" data-number="'.$res['number'].'"></span>' : '').'</td>'; } else { $out.= '<td class="order_btn"><span class="order_open" data-order="'.$res['id'].'">'.__('[:fr]Aller à[:en]Go to order').'</span>'.($_SESSION['auth'] == 1 ? '<span class="delOrder del-icon" data-id="'.$res['id'].'" data-file="'.$res['file'].'" data-number="'.$res['number'].'"></span>' : '').'</td>'; } $out.= '</tr>'; } return $out; } add_action('wp_ajax_orderopen', 'orderopen'); add_action('wp_ajax_nopriv_orderopen', 'orderopen'); function orderopen(){ header("Content-type: application/json; charset=utf-8"); require get_template_directory() . '/bd.php'; $_SESSION['orderopen'] = $_POST['orderid']; if($_SESSION['auth'] != 1) { $order_page = 'single-order'; } if (isset($_SESSION['orderopen'])) { echo '<script>location.href = "/single-order"</script>'; die; } else { echo json_encode(array( 'session' => 'error' )); } } Clicking on the button should initiate an orderopen function related to a particular orderid displayed as "id" inside the table, row by row, in the order the files are uploaded by customers. No result upon clicking.
TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.