Claudia M Posted December 19, 2019 Share Posted December 19, 2019 When looking at an individual order in admin I'd like to add a new tab with my custom information. I have my information added to the notes tab now ( using 2 columns) and it works fine except the save button is in the middle of the information. I'd send a photo but there's a lot of customer info in it. Can someone steer me in the right direction to add a custom tab please? Thanks in advance, Claudia PS: Some of the custom fields are already in CubeCart some I have added to the order.summary database Link to comment Share on other sites More sharing options...
bsmither Posted December 19, 2019 Share Posted December 19, 2019 We can create a simple snippet, or create a full plugin. Let me know when you are ready to create two snippets. Link to comment Share on other sites More sharing options...
Claudia M Posted December 19, 2019 Author Share Posted December 19, 2019 I'm ready. Do you want or need to look at the page I"m talking about in admin first? Link to comment Share on other sites More sharing options...
bsmither Posted December 20, 2019 Share Posted December 20, 2019 Snippet #1: Enabled: checked Unique ID: specialorderdata@cubecart6 Execution Order: 1 Description: Adds a tab to display special order data on it's own content pane Trigger: admin.tabs Version: 1.0 Author: https://forums.cubecart.com/topic/55583-add-tab-in-orders/ PHP Code: <?php if($_GET['_g'] == 'orders' && (!isset($_GET['node']) || $_GET['node'] == 'index') && isset($_GET['action']) && in_array($_GET['action'], array('add','edit'))) { $tab['name'] = 'Special Data'; $tab['tab_id'] = 'tab_specialdata'; $tab['target'] = '#specialdata'; $tabs[] = $tab; } Snippet #2: Enabled: checked Unique ID: specialorderdatapane@cubecart Execution Order: 1 Description: Adds a pane of HTML showing the special data Trigger: admin.order.index.display Version: 1.0 Author: https://forums.cubecart.com/topic/55583-add-tab-in-orders/ PHP Code: <?php ## Put all of the PHP code that processes the special data here. ## Assign to Smarty template variables. For example, $GLOBALS['smarty']->assign('DIV_PANE_ID', "specialdata"); ## ## Put the admin skin template code here. Use Smarty template code to automate the contents. ## Using PHP's NowDoc format, the following div pane is an example of the Smarty template HTML. $specialDataDivPane = <<<'DIVPANE' <div id="{$DIV_PANE_ID}" class="tab_content"> <h3>Special Data</h3> <fieldset> <legend>Special Data Group 1</legend> <div> <label>Data Item 1</label><span>Data Item 1 Value</span> </div> </fieldset> </div> DIVPANE; $specialDataDivPaneCompiled = $GLOBALS['smarty']->fetch('string:'.$specialDataDivPane); ## ## Pass the compiled HTML to a dedicated array. $smarty_data['plugin_tabs'][] = $specialDataDivPaneCompiled Hopefully, this works. I may have some edits later when I try this for real shortly. Link to comment Share on other sites More sharing options...
Claudia M Posted December 20, 2019 Author Share Posted December 20, 2019 Thanks Brian ... I'll implement the snippets and let you know how it goes! I put the first one in hit save and got a white screen. Missing the ' - added it now can see my admin $tab['target'] = '#specialdata; Link to comment Share on other sites More sharing options...
Claudia M Posted December 20, 2019 Author Share Posted December 20, 2019 When I go to another page I get a white screen Link to comment Share on other sites More sharing options...
bsmither Posted December 20, 2019 Share Posted December 20, 2019 Ok, fixed that in the code above. Link to comment Share on other sites More sharing options...
Claudia M Posted December 20, 2019 Author Share Posted December 20, 2019 I deleted the first snippet and can't get in my admin. Just get a white screen. Do you know what this snippet is? It says it was created today at around 2 pm. I didn't create it. <?php $return_filenames = array_map(function($element){return $element['filename'];},$return); array_multisort($return_filenames,$return); ?> Link to comment Share on other sites More sharing options...
bsmither Posted December 20, 2019 Share Posted December 20, 2019 I do not recognize it. If you are looking at the file in the /includes/extra/ folder, the snippet gets recreated after each clearing of the cache. The version cc628 now deletes the snippets when CubeCart clears its cache. Manually deleting the snippet file does not remove it from the database. (Clicking the Delete icon in the list of snippets will delete it, however.) The database table CubeCart_code_snippet does not record when the snippet was inserted into the table. Link to comment Share on other sites More sharing options...
Claudia M Posted December 20, 2019 Author Share Posted December 20, 2019 The first code snippet is working now. I'll do the second now Link to comment Share on other sites More sharing options...
bsmither Posted December 20, 2019 Share Posted December 20, 2019 Made a syntax fix for the second snippet. It's on the last line. I missed a terminating semi-colon. Link to comment Share on other sites More sharing options...
Claudia M Posted December 20, 2019 Author Share Posted December 20, 2019 I have the snippets installed now but how do I input the information. Here is an example of what I'm doing. It shows in 2 columns class= my_width is 590px <div class="my_information" style="width: 1200px;"> <fieldset class="my_width" id="my_left"> <legend>Summary: Product Information</legend> {if !empty($OVERVIEW_SUMMARY.excel_product_name)}<label for="excel_product_name">Excel Product Name:</label> {$OVERVIEW_SUMMARY.excel_product_name}<br>{/if} {if !empty($OVERVIEW_SUMMARY.excel_product_code)}<label for="excel_product_code">Excel Product Code:</label> {$OVERVIEW_SUMMARY.excel_product_code}<br>{/if} </fieldset> <fieldset class="my_right"> <legend>Product Information</legend> <div><label for="excel_product_name">Excel Product Name</label><span><input type="text" id="excel_product_name" name="summary[excel_product_name]" value="{$SUMMARY.excel_product_name}" class="textbox"></span></div> <div><label for="excel_product_code">Excel Product Code</label><span><input type="text" id="excel_product_code" name="summary[excel_product_code]" value="{$SUMMARY.excel_product_code}" class="textbox"></span></div> </fieldset> <fieldset class="my_width" id="my-left"> <legend>Summary: Pricing Information</legend> {if !empty($OVERVIEW_SUMMARY.subtotal)}<label for="order_price">Order Price:</label> {$OVERVIEW_SUMMARY.subtotal}<br>{/if} {if !empty($OVERVIEW_SUMMARY.shipping)}<label for="sold_site">Shipping:</label> {$OVERVIEW_SUMMARY.shipping}<br>{/if} {if !empty($OVERVIEW_SUMMARY.site_discount)}<label for="site_taxes">Total Discount:</label> {$OVERVIEW_SUMMARY.site_discount}<br>{/if} {if !empty($OVERVIEW_SUMMARY.site_taxes)}<label for="site_taxes">Total Taxes:</label> {$OVERVIEW_SUMMARY.site_taxes}<br>{/if} {if !empty($OVERVIEW_SUMMARY.total)}<label for="total">Grand Total:</label> {$OVERVIEW_SUMMARY.total}{/if} </fieldset> <fieldset class="my_right"> <legend>Pricing Information</legend> <div><label for="subtotal">Store Price</label><span>{$OVERVIEW_SUMMARY.subtotal}</span></div> <div><label for="shipping">Store Shipping</label><span>{$OVERVIEW_SUMMARY.shipping}</span></div> <div><label for="site_discount">Site Discount</label><span><input type="text" id="site_discount" name="summary[site_discount]" value="{$SUMMARY.site_discount}" class="textbox"></span></div> <div><label for="site_taxes">Total Taxes</label><span><input type="text" id="site_taxes" name="summary[site_taxes]" value="{$SUMMARY.site_taxes}" class="textbox"></span></div> <div><label for="total">Grand Total</label><span>{$OVERVIEW_SUMMARY.total}</span></div> </fieldset> Link to comment Share on other sites More sharing options...
bsmither Posted December 20, 2019 Share Posted December 20, 2019 How do you input the information? How do you do it now? Or do you mean, how to modify the second snippet to show the template code above? Link to comment Share on other sites More sharing options...
Claudia M Posted December 20, 2019 Author Share Posted December 20, 2019 Now I add the code (see above) to the admin/skin/order.index file affixing it to the "notes" tab. But I wanted its own tab because I use it in 2 columns and the save button was showing in the middle and not allowing my columns to line up. Yes I wanted to know how to modify the snippet to show the information Link to comment Share on other sites More sharing options...
bsmither Posted December 20, 2019 Share Posted December 20, 2019 Grab all of what you added to the Notes section of the template, and move it to the snippet: Between these two lines: $specialDataDivPane = <<<'DIVPANE' and: DIVPANE; There will be a few tweaks to that template code. The opening <div> needs id="specialdata". (And I think you didn't paste all of the custom code. Am I right?) Link to comment Share on other sites More sharing options...
Claudia M Posted December 20, 2019 Author Share Posted December 20, 2019 No I didn't paste all me code. I'll make the changes now. Thank you! Link to comment Share on other sites More sharing options...
Claudia M Posted December 20, 2019 Author Share Posted December 20, 2019 The save reload button has disappeared from the notes tab and the save button is still in the center of my code on the Special Tab. Here's the beginning and end of the info I put in the snippet. # Using PHP's NowDoc format, the following div pane is an example of the Smarty template HTML. $specialDataDivPane = <<<'DIVPANE' <div id="specialdata" class="tab_content"> <h3>Special Data</h3> <div class="my_information" style="width: 1200px;"> <fieldset class="my_width" id="my_left"> -------------------------- <div><label for="weight">AIOS Order Weight</label><span>{$OVERVIEW_SUMMARY.weight}</span></div> <div><label for="ship_product">Shipping Paid For</label><span>{$OVERVIEW_SUMMARY.ship_product}</span></div> <div><label for="shipping_used">Shipping Used</label><span><input type="text" id="shipping_used" name="summary[shipping_used]" value="{$SUMMARY.shipping_used}" class="textbox"></span></div> <div><label for="shipping_zone">Shipping Zone</label><span><input type="text" id="shipping_zone" name="summary[shipping_zone]" value="{$SUMMARY.shipping_zone}" class="textbox"></span></div> </fieldset> </div> DIVPANE; $specialDataDivPaneCompiled = $GLOBALS['smarty']->fetch('string:'.$specialDataDivPane); ## ## Pass the compiled HTML to a dedicated array. $smarty_data['plugin_tabs'][] = $specialDataDivPaneCompiled; Link to comment Share on other sites More sharing options...
bsmither Posted December 20, 2019 Share Posted December 20, 2019 PM sent. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.