-1

代码是这样的

$.get(
            //'index.php?route=sale/order/infoforhome&token=<?php echo $token; ?>', 
            'index.php?route=common/home/orderinfo&token=<?php echo $token; ?>', 
            { 'order_id' : id }, 
            function(data){
                if(data)
                {
                        html =  '<div class="vtabs">' + 
                                '<?php if ($this->config->get(\'sales_order_detail\')) { ?>' +
                                '<a href="#tab-order"><?php echo $tab_order; ?></a>'+ 
                                '<?php } ?>' + 
                                '<?php if ($this->config->get(\'sales_payment_detail\')) { ?>' + 
                                '<a href="#tab-payment"><?php echo $tab_payment; ?></a>' + 
                                '<?php } ?>' + 
                                '<?php if ($shipping_method) { ?>' +
                                '<?php if ($this->config->get(\'sales_shipping_detail\')) { ?>' +
                                '<a href="#tab-shipping"><?php echo $tab_shipping; ?></a>' + 
                                '<?php } ?>' +
                                '<?php } ?>' +
                                '<?php if ($this->config->get(\'sales_product\')) { ?>' + 
                                    '<a href="#tab-product">'+
                                        '<?php echo $tab_product; ?>'+
                                    '</a>'+
                                '<?php } ?>'+
                                '<?php if ($this->config->get(\'sales_order_history\')) { ?>' + 
                                    '<a href="#tab-history">' + 
                                        '<?php echo $tab_order_history; ?>' + 
                                    '</a>' + 
                                '<?php } ?>' + 
                                '</div>' +
                                '<?php if ($this->config->get(\'sales_order_detail\')) { ?>' +
                                '<div id="tab-order" class="vtabs-content">' +
                                '<table class="form">' +
                                    '<tr>' +
                                        '<td><?php echo $text_order_id; ?></td>' +
                                        '<td>#' + data['order_id'] + '</td>' +
                                    '</tr>' +
                                '<tr>' +
                                    '<td><?php echo $text_invoice_no; ?></td>' +
                                    '<td><?php if (' + data['invoice_no'] + '){ ?>' +
                                        data['invoice_no'] +
                                        '<?php } else { ?>' +
                                        '<span id="invoice"><b>[</b> <a id="invoice-generate"><?php echo $text_generate; ?></a> <b>]</b></span>' +
                                    '<?php } ?></td>'+
                                '</tr>'+
                                '<tr>'+
                                    '<td><?php echo $text_store_name; ?></td>' +
                                    '<td>'+ data['store_name'] +'</td>' +
                                '</tr>' +
                                '<tr>' +
                                    '<td><?php echo $text_store_url; ?></td>' +
                                    '<td><a onclick="window.open(\''+ data[store_url] +'\');"><u>' + data['store_url'] + '</u></a></td>' +
                                '</tr>' +
                                '<?php if (' + data['customer'] + ') { ?>' +
                                '<tr>' +
                                    '<td><?php echo $text_customer; ?></td>' +
                                    '<td><a href="' + data['customer'] + '">' + data['firstname'] + ' ' + data['lastname'] + '</a></td>' +
                                '</tr>' +
                                '<?php } else { ?>' +
                                '<tr>' +
                                    '<td><?php echo $text_customer; ?></td>' +
                                    '<td>' + data['firstname'] + ' ' + data['lastname'] + '</td>' +
                                '</tr>' +
                                '<?php } ?>' +
                                '<?php if (' + data['customer_group'] + ') { ?>' +
                                '<tr>' +
                                    '<td><?php echo $text_customer_group; ?></td>' +
                                    '<td>' + data['customer_group'] + '</td>' +
                                '</tr>' +
                                '<?php } ?>' +
                                '<tr>' +
                                    '<td><?php echo $text_ip; ?></td>' +
                                    '<td>'+ data['ip']+'</td>' +
                                '</tr>' +
                                '<tr>' +
                                    '<td><?php echo $text_email; ?></td>' +
                                    '<td>' + data['email'] + '</td>' +
                                '</tr>' +
                                '<tr>' +
                                    '<td><?php echo $text_telephone; ?></td>' +
                                    '<td>' + data['telephone'] + '</td>' +
                                '</tr>'+
                                '<tr>' +
                                    '<td><?php echo $text_mobilephone; ?></td>' +
                                    '<td>' + data['mobilenumber'] + '</td>' +
                                '</tr>'+
                                '<?php if ('+data['fax']+') { ?>' +
                                '<tr>' +
                                    '<td><?php echo $text_fax; ?></td>' +
                                    '<td>' + data['fax'] + '</td>' +
                                '</tr>' +
                                '<?php } ?>' +
                                '<tr>' +
                                    '<td><?php echo $text_total; ?></td>' +
                                    '<td>' + data['total'] +
                                    '<?php if (' + data['credit'] + '&&' + data['customer'] + ') { ?>' +
                                    '<?php if (!' + data['credit_total'] + ') { ?>' +
                                    '<span id="credit"><b>[</b> <a id="credit-add"><?php echo $text_credit_add; ?></a> <b>]</b></span>' +
                                    '<?php } else { ?>' +
                                    '<span id="credit"><b>[</b> <a id="credit-remove"><?php echo $text_credit_remove; ?></a> <b>]</b></span>' +
                                    '<?php } ?>' +
                                    '<?php } ?></td>' +
                                '</tr>' +

                                '<?php if ($order_status) { ?>' +
                                '<tr>' +
                                    '<td><?php echo $text_order_status; ?></td>'+
                                    '<td id="order-status">' + data['order_status'] + '</td>'+
                                '</tr>'+
                                '<?php } ?>'+
                                '<?php if (' + data['comment'] + ') { ?>'+
                                '<tr>'+
                                    '<td><?php echo $text_comment; ?></td>'+
                                    '<td>' + data['comment'] + '</td>'+
                                '</tr>'+
                                '<?php } ?>'+
                                '<?php if (' + data['affiliate'] + ') { ?>'+
                                '<tr>'+
                                    '<td><?php echo $text_affiliate; ?></td>'+
                                    '<td><a href="' + data['affiliate'] + '">' + data['affiliate_firstname'] + ' ' + data['affiliate_lastname'] + '</a></td>'+
                                '</tr>'+
                                '<tr>'+
                                    '<td><?php echo $text_commission; ?></td>'+
                                    '<td>' + data['commission'] +
                                    '<?php if (!' + data['commission_total'] + ') { ?>'+
                                    '<span id="commission"><b>[</b> <a id="commission-add"><?php echo $text_commission_add; ?></a> <b>]</b></span>'+
                                    '<?php } else { ?>'+
                                    '<span id="commission"><b>[</b> <a id="commission-remove"><?php echo $text_commission_remove; ?></a> <b>]</b></span>'+
                                    '<?php } ?></td>'+
                                    '</tr>'+
                                    '<?php } ?>'+
                                    '<tr>'+
                                      '<td><?php echo $text_date_added; ?></td>'+
                                      '<td>' + data['date_added'] + '</td>'+
                                    '</tr>'+
                                    '<tr>'+
                                      '<td><?php echo $text_date_modified; ?></td>'+
                                      '<td>' +data['date_modified']+'</td>'+
                                    '</tr>'+
                                  '</table>'+
                                '</div>'+
                                '<?php } ?>'+
                                '<?php if ($this->config->get(\'sales_payment_detail\')) { ?>'+
                                '<div id="tab-payment" class="vtabs-content">'+
                                '<table class="form">'+
                                '<tr>'+
                                    '<td><?php echo $text_firstname; ?></td>'+
                                    '<td>'+ data['payment_firstname'] +'</td>'+
                                '</tr>'+
                                '<tr>'+
                                  '<td><?php echo $text_lastname; ?></td>'+
                                  '<td>' + data['payment_lastname'] + '</td>'+
                                '</tr>'+
                                '<?php if (' + data['payment_company'] +') { ?>'+
                                '<tr>'+
                                  '<td><?php echo $text_company; ?></td>'+
                                  '<td>' + data['payment_company']+ '</td>'+
                                '</tr>'+
                                '<?php } ?>'+
                                '<tr>'+
                                  '<td><?php echo $text_address_1; ?></td>'+
                                  '<td>' + data['payment_address_1'] + '</td>'+
                                '</tr>'+
                                '<?php if (' + data['payment_address_2'] + ') { ?>'+
                                '<tr>'+
                                  '<td><?php echo $text_address_2; ?></td>'+
                                  '<td>' +data['payment_address_2']+'</td>'+
                                '</tr>'+
                                '<?php } ?>'+
                                '<tr>'+
                                  '<td><?php echo $text_city; ?></td>'+
                                  '<td>' + data['payment_city'] + '</td>'+
                                '</tr>'+
                                '<?php if (' + data['payment_postcode'] + ') { ?>'+
                                '<tr>'+
                                  '<td><?php echo $text_postcode; ?></td>'+
                                  '<td>' + data['payment_postcode'] + '</td>'+
                                '</tr>'+
                                '<?php } ?>'+
                                '<tr>'+
                                  '<td><?php echo $text_zone; ?></td>'+
                                  '<td>' + data['payment_zone'] + '</td>'+
                                '</tr>'+
                                '<?php if (' + data['payment_zone_code'] + ') { ?>'+
                                '<tr>'+
                                  '<td><?php echo $text_zone_code; ?></td>'+
                                  '<td>' + data['payment_zone_code'] + '</td>'+
                                '</tr>'+
                                '<?php } ?>'+
                                '<tr>'+
                                  '<td><?php echo $text_country; ?></td>'+
                                  '<td>' + data['payment_country'] + '</td>'+
                                '</tr>'+
                                '<tr>'+
                                  '<td><?php echo $text_payment_method; ?></td>'+
                                  '<td>' + data['payment_method'] + '</td>'+
                                '</tr>'+
                              '</table>'+
                            '</div>'+
                            '<?php } ?>'+
                            '<?php if ($this->config->get(\'sales_shipping_detail\')) { ?>'+
                            '<?php if ($shipping_method) { ?>'+
                            '<div id="tab-shipping" class="vtabs-content">'+
                            '<table class="form">'+
                                '<tr>'+
                                    '<td><?php echo $text_firstname; ?></td>'+
                                    '<td>' + data['shipping_firstname'] + '</td>'+
                                '</tr>'+
                            '<tr>'+
                              '<td><?php echo $text_lastname; ?></td>'+
                              '<td>' + data['shipping_lastname'] + '</td>'+
                            '</tr>'+
                            '<?php if (' + data['shipping_company']+ ') { ?>'+
                            '<tr>'+
                              '<td><?php echo $text_company; ?></td>'+
                              '<td>' + data['shipping_company']+'</td>'+
                            '</tr>'+
                            '<?php } ?>'+
                            '<tr>'+
                              '<td><?php echo $text_address_1; ?></td>'+
                              '<td>' + data['shipping_address_1'] + '</td>'+
                            '</tr>'+
                            '<?php if (' + data['shipping_address_2'] + ') { ?>'+
                            '<tr>'+
                              '<td><?php echo $text_address_2; ?></td>'+
                              '<td>' + data['shipping_address_2'] + '</td>'+
                            '</tr>'+
                            '<?php } ?>'+
                            '<tr>'+
                              '<td><?php echo $text_city; ?></td>'+
                              '<td>' + data['shipping_city'] + '</td>'+
                            '</tr>'+
                            '<?php if (' + data['shipping_postcode'] + ') { ?>'+
                            '<tr>'+
                              '<td><?php echo $text_postcode; ?></td>'+
                              '<td>' + data['shipping_postcode'] + '</td>'+
                            '</tr>'+
                            '<?php } ?>'+
                            '<tr>'+
                              '<td><?php echo $text_zone; ?></td>'+
                              '<td>' + data['shipping_zone'] + '</td>'+
                            '</tr>'+
                            '<?php if (' + data['shipping_zone_code'] + ') { ?>'+
                            '<tr>'+
                              '<td><?php echo $text_zone_code; ?></td>'+
                              '<td>' + data['shipping_zone_code'] + '</td>'+
                            '</tr>'+
                            '<?php } ?>'+
                            '<tr>'+
                              '<td><?php echo $text_country; ?></td>'+
                              '<td>' + data['shipping_country'] + '</td>'+
                            '</tr>'+
                            '<?php if (' + data['shipping_method']+') { ?>'+
                            '<tr>'+
                              '<td><?php echo $text_shipping_method; ?></td>'+
                              '<td>' + data['shipping_method'] + '</td>'+
                            '</tr>'+
                            '<?php } ?>'+
                          '</table>'+
                        '</div>'+
                        '<?php } ?>'+
                            '<?php } ?>'+
                            '<?php if ($this->config->get(\'sales_product\')) { ?>'+
                        '<div id="tab-product" class="vtabs-content">'+
                          '<table id="product" class="list">'+
                            '<thead>'+
                              '<tr>'+
                                '<td class="left"><?php echo $column_product; ?></td>'+
                                '<td class="left"><?php echo $column_model; ?></td>'+
                                '<td class="right"><?php echo $column_quantity; ?></td>'+
                                '<td class="right"><?php echo $column_price; ?></td>'+
                                '<td class="right"><?php echo $column_total; ?></td>'+
                              '</tr>'+
                            '</thead>'+
                            '<?php foreach (' + data['products'] = ' as $product) { ?>'+
                            '<tbody id="product-row<?php echo $product[\'order_product_id\']; ?>">'+
                              '<tr>'+
                                '<td class="left"><?php if ($product[\'product_id\']) { ?>'+
                                  '<a href="<?php echo $product[\'href\']; ?>"><?php echo $product[\'name\']; ?></a>'+
                                  '<?php } else { ?>'+
                                  '<?php echo $product[\'name\']; ?>'+
                                  '<?php } ?>'+
                                  '<?php foreach ($product[\'option\'] as $option) { ?>'+
                                  '<br />'+
                                  '<?php if ($option[\'type\'] != \'file\') { ?>'+
                                  '&nbsp;<small> - <?php echo $option[\'name\']; ?>: <?php echo $option[\'value\']; ?></small>'+
                                  '<?php } else { ?>'+
                                  '&nbsp;<small> - <?php echo $option[\'name\']; ?>: <a href="<?php echo $option[\'href\']; ?>"><?php echo $option[\'value\']; ?></a></small>'+
                                  '<?php } ?>'+
                                  '<?php } ?></td>'+
                                '<td class="left"><?php echo $product[\'model\']; ?></td>'+
                                '<td class="right"><?php echo $product[\'quantity\']; ?></td>'+
                                '<td class="right"><?php echo $product[\'price\']; ?></td>'+
                                '<td class="right"><?php echo $product[\'total\']; ?></td>'+
                              '</tr>'+
                            '</tbody>'+
                            '<?php } ?>'+
                            '<tbody id="totals">'+
                            '<tr>'+
                                '<td colspan="4" class="right"><?php echo $text_subtotal; ?> :</td>'+
                                '<td class="right">' + data['subtotal'] + '</td>'+
                            '</tr>'+
                            '<?php if (' + data['shipping_weight'] + ') { ?>'+
                            '<tr>'+
                                '<td colspan="4" class="right">' + data['shipping_weight'] + ' :</td>'+
                                '<td class="right">' + data['shipping_cost'] + '</td>'+
                            '</tr>'+
                            '<?php } ?>'+
                            '<tr>'+
                                '<td colspan="4" class="right"><?php echo $text_total; ?> :</td>'+
                                '<td class="right">' + data['totals'] + '</td>'+
                            '</tr>'+
                            '</tbody>'+
                          '</table>'+
                          '<?php if (' +data['downloads'] + ') { ?>'+
                          '<h3><?php echo $text_download; ?></h3>'+
                          '<table class="list">'+
                            '<thead>'+
                              '<tr>'+
                                '<td class="left"><b><?php echo $column_download; ?></b></td>'+
                                '<td class="left"><b><?php echo $column_filename; ?></b></td>'+
                                '<td class="right"><b><?php echo $column_remaining; ?></b></td>'+
                              '</tr>'+
                            '</thead>'+
                            '<tbody>'+
                              '<?php foreach (' + data['downloads'] + ' as $download) { ?>'+
                              '<tr>'+
                                '<td class="left"><?php echo $download[\'name\']; ?></td>'+
                                '<td class="left"><?php echo $download[\'filename\']; ?></td>'+
                                '<td class="right"><?php echo $download[\'remaining\']; ?></td>'+
                              '</tr>'+
                              '<?php } ?>'+
                            '</tbody>'+
                          '</table>'+
                          '<?php } ?>'+
                        '</div>'+
                            '<?php } ?>'+
                            '<?php if ($this->config->get(\'sales_order_history\')) { ?>'+
                        '<div id="tab-history" class="vtabs-content">'+
                          '<div id="history"></div>'+
                          '<table class="form">'+
                            ' <?php if ($this->config->get(\'sales_order_history_update\')) { ?>' +
                            '<tr>'+
                              '<td><?php echo $entry_order_status; ?></td>'+
                              '<td><select name="order_status_id">'+
                                  '<?php foreach (' + data['order_statuses'] + '  as $order_statuses) { ?>' +
                                  '<?php if ($order_statuses[\'order_status_id\'] == $order_status_id) { ?>' +
                                  '<option value="<?php echo $order_statuses[\'order_status_id\']; ?>" selected="selected"><?php echo $order_statuses[\'name\']; ?></option>'+
                                  '<?php } else { ?>' +
                                  '<option value="<?php echo $order_statuses[\'order_status_id\']; ?>"><?php echo $order_statuses[\'name\']; ?></option>' +
                                  '<?php } ?>'+
                                  '<?php } ?>'+
                                '</select></td>'+
                            '</tr>'+
                                '<tr>'+
                              '<td><?php echo $entry_notify; ?></td>'+
                              '<td><input type="checkbox" name="notify" value="1" /></td>'+
                            '</tr>'+
                            '<tr>'+
                              '<td><?php echo $entry_comment; ?></td>'+
                              '<td><textarea name="comment" cols="40" rows="8" style="width: 99%"></textarea>'+
                                '<div style="margin-top: 10px; text-align: right;"><a onclick="history();" id="button-history" class="button"><?php echo $button_add_history; ?></a></div></td>'+
                            '</tr>'+
                            '<?php } ?>' +
                        '</table>' +
                        '</div>' +
                        '<?php } ?>'; //Getting Error on this line on Netbeans IDE

                      $('div.latest_detail div#oder_detail').html(html);
                }
                else
                {
                    $('#order_detail').html('Sorry No Details exists for this order in the database');
                }
            }, 'json');

我正在修改开放式购物车。对不起,如果我做错了。我厌倦了寻找错误但无法解决它。在浏览器上运行此程序后出现的错误是

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, 
expecting T_STRING in 
C:\Server\Zend\Apache2\htdocs\oc\admin\view\template\common\home.tpl on line 522

在 Netbeans IDE 上,它向我显示了之前 html 最后一行左侧无效分配的建议

$('div.latest_detail div#oder_detail').html(html);

请帮忙。??提前致谢。

4

2 回答 2

3

正如其他人指出的那样,您最大的问题是您试图if-then在 JavaScript 代码中使用 PHP 逻辑。这是行不通的,因为 PHP 在服务器端运行而 JavaScript 在客户端运行,所以它们不可能相互交互。

但是,即使没有这个,用 JavaScript 编写冗长的 HTML 代码块也很麻烦且没有必要。更好的方法是在 HTML 中编写该代码并使用 CSS with 将其隐藏,然后根据需要display:none使用 jQuery 。show()

于 2012-09-17T14:45:04.880 回答
1

您的问题在这里:

'<td><?php if (' + data['invoice_no'] + '){ ?>' +

这将变成:

<?php if (123435-ABC) { ?>
于 2012-09-17T14:51:29.373 回答