Spade

Mini Shell

Directory:~$ /home/lmsyaran/www/joomla4/
Upload File

[Home] [System Details] [Kill Me]
Current File:~$ /home/lmsyaran/www/joomla4/add_product_to_hikashop.zip

PKh��[�t�N		add_product_to_hikashop.phpnu�[���<?php
/*----------------------------------------------------------------------------------|
 www.vdm.io  |----/
				fdsh 
/-------------------------------------------------------------------------------------------------------/

	@version		1.0.36
	@build			27th July, 2021
	@created		17th December, 2020
	@package		Reservation
	@subpackage		add_product_to_hikashop.php
	@author			farhad shahbazi <http://farhad.com>	
	@copyright		Copyright (C) 2015. All Rights Reserved
	@license		GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html
  ____  _____  _____  __  __  __      __       ___  _____  __  __  ____ 
_____  _  _  ____  _  _  ____ 
 (_  _)(  _  )(  _  )(  \/  )(  )    /__\     / __)(  _  )(  \/  )(  _ \( 
_  )( \( )( ___)( \( )(_  _)
.-_)(   )(_)(  )(_)(  )    (  )(__  /(__)\   ( (__  )(_)(  )    (  )___/
)(_)(  )  (  )__)  )  (   )(  
\____) (_____)(_____)(_/\/\_)(____)(__)(__)   \___)(_____)(_/\/\_)(__) 
(_____)(_)\_)(____)(_)\_) (__) 

/------------------------------------------------------------------------------------------------------*/

// No direct access to this file
defined('_JEXEC') or die('Restricted access');


/***[JCBGUI.class_extends.head.1.$$$$]***/

use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\Plugin\CMSPlugin;
/***[/JCBGUI$$$$]***/


/***[JCBGUI.class_extends.comment.1.$$$$]***/
/**
 * Content - Add_product_to_hikashop plugin.
 *
 * @package   Add_product_to_hikashop
 * @since     1.0.0
 *//***[/JCBGUI$$$$]***/

class PlgContentAdd_product_to_hikashop extends CMSPlugin
{
    public function onContentAfterSave($context, $table, $isNew)
    {

        if ($context != 'com_reservation.plan')
            return true;


        // file_put_contents($file_name, "data if =
".print_r($data, true) . "\n", FILE_APPEND);
        jimport( 'joomla.plugin.plugin' );
        // file_put_contents($file_name, "data !!! =
".print_r($data, true) . "\n", FILE_APPEND);


        require_once(
JPATH_ADMINISTRATOR.'/components/com_hikashop/helpers/helper.php'
);
//        require_once(
JPATH_SITE.'/components/com_reservation/helpers/reservation.php'
);
        $config = hikashop_config();
        $allowed = $config->get('allowedfiles');
        $imageHelper = hikashop_get('helper.image');

        $file_class = hikashop_get('class.file');
        $uploadPath =
$file_class->getPath('product','');
//        $params = JComponentHelper::getParams('com_moojla');
//        $courses_category =
trim($params->get('courses_category'));

//        $course = $data["course_id"];
//        $db = JFactory::getDbo();
//
//        $db = JFactory::getDbo();
//        $query = $db->getQuery(true);
//        $query->select($db->quoteName(array('id',
'summary_files')))
//            ->from($db->quoteName('#__moojla_course'))
//            ->where($db->quoteName('remoteid') . ' =
' . $db->quote($course));
//        $db->setQuery($query);
//        $moojla_course = $db->loadAssoc();

        //  New product to add to Hikashop
        $plans= [
            1 => 'مشاوره تلفنی',
            2 => 'مشاوره چت آنلاین'
        ];

//        $name = $data["course_name"];
        $plan_type= $plans[$table->get('plantype')];
        $consultant=
ReservationHelper::getConsultant($table->get('consultantid'));
        $consultant_name= $consultant->name;
        $consultant_specialty= $consultant->title;
        $name = $plan_type.' -
'.$consultant_name.'('.$consultant_specialty.')';

//        echo '<pre>';
//        var_dump($table->get('waitingtime'),
$table->get('time'));
//        echo '</pre>';
//        exit();
//        $desc = "
میباشد{$table->get('waitingtime')} برگزار
میگردد و حداکثر زمان لازم برای پاسخگویی
دکتر {$table->get('time')}این پلن به مدت
";
        $desc = "این پلن به مدت
{$table->get('time')} دقیقه برگزار میگردد و
حداکثر زمان لازم برای پاسخگویی دکتر
{$table->get('waitingtime')} ساعت میباشد";
        $cost = $table->price;
        $plan_id = $table->id;
//        $currency = $data["currency"];
        $currency = 'USD';
//        $courses_category= [$plan_type, $consultant->specialty];
//        $courses_category= [14];


        $product_class = hikashop_get('class.product');
        $element = new JObject ();
//        $element->categories = $courses_category;
        $element->related = array();
        $element->options = array();
        $element->product_name = $name;
        $element->product_description = $desc;
        $element->product_code = $plan_id;
        $element->product_published = 1;
        $element->product_min_per_order = 0;
        $element->product_max_per_order = 1;

        $db = JFactory::getDbo();
        $query = $db->getQuery(true);
       
$query->select($db->quoteName(array('category_id')));
       
$query->from($db->quoteName('#__hikashop_category'));
        $query->where($db->quoteName('category_namekey') .
' = ' . $db->quote('default_tax'));

        $db->setQuery($query);
        $tax_id = $db->loadResult();

        if ($tax_id)
        {
            $element->product_tax_id = $tax_id;

            $db = JFactory::getDbo();
            $query = $db->getQuery(true);
           
$query->select($db->quoteName(array('tax_namekey')));
           
$query->from($db->quoteName('#__hikashop_taxation'));
           
$query->where($db->quoteName('category_namekey') . ' =
' . $db->quote('default_tax'));
            $db->setQuery($query);
            $tax_namekey = $db->loadResult();

            $db = JFactory::getDbo();
            $query = $db->getQuery(true);
           
$query->select($db->quoteName(array('tax_rate')));
           
$query->from($db->quoteName('#__hikashop_tax'));
            $query->where($db->quoteName('tax_namekey') .
' = ' . $db->quote($tax_namekey));
            $db->setQuery($query);
            $tax_rate = $db->loadResult();

            $div = $tax_rate + 1;
            $price_without_tax = $cost / $div;
            $cost = $price_without_tax;
        }

        $db = JFactory::getDbo();
        $query = $db->getQuery(true);
       
$query->select($db->quoteName(array('product_id')));
       
$query->from($db->quoteName('#__hikashop_product'));
        $query->where($db->quoteName('product_code') .
' = ' . $db->quote($plan_id));
        $db->setQuery($query);
        $products = $db->loadObjectList();

        $db->setQuery($query);
        $products = $db->loadObjectList();
        // // file_put_contents($file_name, "query =
".print_r($query->__toString(), true) . "\n",
FILE_APPEND);
        // file_put_contents($file_name, "products =
".print_r($products, true) . "\n", FILE_APPEND);
        if (count ($products))
        {
            $element->product_id = current($products)->product_id;
        }



        $element->prices[0] = new JObject ();
        $element->prices[0]->price_value = $cost;

        $db = JFactory::getDbo();
        $query = $db->getQuery(true);
       
$query->select($db->quoteName(array('currency_id')));
       
$query->from($db->quoteName('#__hikashop_currency'));
        $query->where($db->quoteName('currency_code') .
' = ' . $db->quote($currency));
        $db->setQuery($query);
        $currency_id = $db->loadResult();


        $element->prices[0]->price_currency_id = $currency_id;
        $element->prices[0]->price_min_quantity = 0;
        $element->product_type = "main";
//        $quantity = intval($enrol_json['customint3']);
        $quantity = 0;
        if($quantity > 0)
            $element->product_quantity = $quantity;

        $status = $product_class->save($element);


        if ($status)
        {
            $product_class->updateCategories($element,$status);
            $product_class->updatePrices($element,$status);
        }
        
        echo '<pre>';
        var_dump($consultant);
        echo '</pre>';
        exit();

    }
}
PKh��[��	add_product_to_hikashop.xmlnu�[���<?xml
version="1.0" encoding="utf-8"?>
<extension type="plugin" version="3.8"
group="content" method="upgrade">
	<name>PLG_CONTENT_ADD_PRODUCT_TO_HIKASHOP</name>
	<creationDate>27th July, 2021</creationDate>
	<author>farhad shahbazi</author>
	<authorEmail>farhad.shahbazi0010@gmail.com</authorEmail>
	<authorUrl>http://farhad.com</authorUrl>
	<copyright>Copyright (C) 2015. All Rights Reserved</copyright>
	<license>GNU/GPL Version 2 or later -
http://www.gnu.org/licenses/gpl-2.0.html</license>
	<version>1.0.0</version>
	<description>PLG_CONTENT_ADD_PRODUCT_TO_HIKASHOP_XML_DESCRIPTION</description>

	<!-- Language files -->
	<languages folder="language">
		<language
tag="en-GB">en-GB/en-GB.plg_content_add_product_to_hikashop.ini</language>
		<language
tag="en-GB">en-GB/en-GB.plg_content_add_product_to_hikashop.sys.ini</language>
	</languages>

	<!-- Plugin files -->
	<files>
		<filename
plugin="add_product_to_hikashop">add_product_to_hikashop.php</filename>
		<filename>index.html</filename>
		<folder>language</folder>
	</files>
</extension>PKh��[�#o,,
index.htmlnu�[���<html><body
bgcolor="#FFFFFF"></body></html>PKh��[�Q\\<language/en-GB/en-GB.plg_content_add_product_to_hikashop.ininu�[���PLG_CONTENT_ADD_PRODUCT_TO_HIKASHOP="Content
- Add_product_to_hikashop"
PLG_CONTENT_ADD_PRODUCT_TO_HIKASHOP_XML_DESCRIPTION="<h1>Content
- Add_product_to_hikashop (v.1.0.0)</h1> <div style='clear:
both;'></div><p>Created by <a
href='http://farhad.com' target='_blank'>farhad
shahbazi</a><br /><small>Development started 27th July,
2021</small></p>"PKh��[�Q\\@language/en-GB/en-GB.plg_content_add_product_to_hikashop.sys.ininu�[���PLG_CONTENT_ADD_PRODUCT_TO_HIKASHOP="Content
- Add_product_to_hikashop"
PLG_CONTENT_ADD_PRODUCT_TO_HIKASHOP_XML_DESCRIPTION="<h1>Content
- Add_product_to_hikashop (v.1.0.0)</h1> <div style='clear:
both;'></div><p>Created by <a
href='http://farhad.com' target='_blank'>farhad
shahbazi</a><br /><small>Development started 27th July,
2021</small></p>"PKh��[�#o,,language/en-GB/index.htmlnu�[���<html><body
bgcolor="#FFFFFF"></body></html>PKh��[�#o,,language/index.htmlnu�[���<html><body
bgcolor="#FFFFFF"></body></html>PKh��[�t�N		add_product_to_hikashop.phpnu�[���PKh��[��	Tadd_product_to_hikashop.xmlnu�[���PKh��[�#o,,
�#index.htmlnu�[���PKh��[�Q\\<!$language/en-GB/en-GB.plg_content_add_product_to_hikashop.ininu�[���PKh��[�Q\\@�%language/en-GB/en-GB.plg_content_add_product_to_hikashop.sys.ininu�[���PKh��[�#o,,�'language/en-GB/index.htmlnu�[���PKh��[�#o,,*(language/index.htmlnu�[���PK��(