Need help with hook for shipping module
Posted: Tue Aug 09, 2022 4:44 am
Hello,
I have a shipping module that was coded to have a tab in the product edit area where a different shipping price can be set for each product. The issue is the tab isn't showing and I believe the issue is in the hook file. There are no errors in the error logs. Below is the code of the hook file. I appreciate any help. Thanks
I have a shipping module that was coded to have a tab in the product edit area where a different shipping price can be set for each product. The issue is the tab isn't showing and I believe the issue is in the hook file. There are no errors in the error logs. Below is the code of the hook file. I appreciate any help. Thanks
Code: Select all
<?php
/*
This work is licensed under a
Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.
You should have received a copy of the license along with this work.
If not, see <http://creativecommons.org/licenses/by-nc-nd/4.0/>.
*/
class hook_admin_categories_shipping {
var $version = '1.0.0';
function listen_productTab() {
global $pInfo;
$this->load_lang();
$tab_title = addslashes(SHIPPING_TITLE);
$tab_link = '#section_shipping';
$add_edit_intro = SHIPPING_INTRO;
$handling_title = HANDLING_TITLE;
$extra_title = EXTRA_TITLE;
$handling_input = tep_draw_input_field('products_handling_shipping', $pInfo->products_handling_shipping ?? null, 'autocomplete="off" class="form-control w-25"');
$extra_input = tep_draw_input_field('products_extra_shipping', $pInfo->products_extra_shipping ?? null, 'autocomplete="off" class="form-control w-25"');
$output = <<<EOD
<script>
$(function() {
$('#productTabs ul.nav.nav-tabs').append('<li class="nav-item"><a class="nav-link" data-toggle="tab" href="{$tab_link}" role="tab">{$tab_title}</a></li>');
});
</script>
<div class="tab-pane fade" id="section_shipping" role="tabpanel">
<div class="alert alert-info">
{$add_edit_intro}
</div>
<table class="table table-sm">
<tr>
<th class="text-right">{$handling_title} </th>
<td>{$handling_input}</td>
</tr>
<tr>
<th class="text-right">{$extra_title} </th>
<td>{$extra_input}</td>
</tr>
</table>
</div>
EOD;
return $output;
}
function listen_productActionSave() {
global $products_id;
$insert_sql_data = ['products_handling_shipping' => tep_db_prepare_input($_POST['products_handling_shipping']),
'products_extra_shipping' => tep_db_prepare_input($_POST['products_extra_shipping'])];
tep_db_perform('products', $insert_sql_data, 'update', "products_id = '" . (int)$products_id . "'");
}
function load_lang() {
global $language;
require(DIR_FS_CATALOG . 'includes/languages/' . $language . '/hooks/admin/categories/shipping.php');
}
}