44 lines
1.4 KiB
PHP
44 lines
1.4 KiB
PHP
|
|
<?php
|
||
|
|
namespace Foxstudio\Plugins\Template\Utils;
|
||
|
|
use Foxstudio\Plugins\Template\Repository as Repository;
|
||
|
|
class ProductDescriptionTab {
|
||
|
|
public function __construct()
|
||
|
|
{
|
||
|
|
add_filter('woocommerce_product_description_heading', '__return_null');
|
||
|
|
add_filter('woocommerce_product_tabs', [$this, 'addCustomTab']);
|
||
|
|
}
|
||
|
|
|
||
|
|
function addCustomTab($tabs)
|
||
|
|
{
|
||
|
|
|
||
|
|
// Adds the new tab
|
||
|
|
|
||
|
|
$tabs['product_description_tab'] = array(
|
||
|
|
'title' => __('O produkcie', 'pandaGadzety'),
|
||
|
|
'priority' => 50,
|
||
|
|
'callback' => [$this, 'customTabData']
|
||
|
|
);
|
||
|
|
|
||
|
|
return $tabs;
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
public function customTabData()
|
||
|
|
{
|
||
|
|
global $product;
|
||
|
|
\wp_enqueue_style("descriptionStyle", plugins_url("/pandaGadzety/assets/css/description.css"));
|
||
|
|
$sku = $product->get_sku();
|
||
|
|
$product_repository = new Repository\ProductRepository(SERVER_URL);
|
||
|
|
$results = $product_repository->getProductDescription($sku);
|
||
|
|
|
||
|
|
echo "<div id='description-tab'>";
|
||
|
|
echo $results['short_description'];
|
||
|
|
echo "<table><tr><th colspan='2'>Informacje o produkcie</th></tr>";
|
||
|
|
foreach ($results['specification'] as $key => $value) {
|
||
|
|
echo "<tr><td>".$value['name']."</td><td>".$value['value']."</td></tr>";
|
||
|
|
}
|
||
|
|
echo "</table>";
|
||
|
|
echo "</div>";
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|