News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

New To Plugins

Started by Picklehead, January 08, 2023, 18:39:36 PM

Previous topic - Next topic

Picklehead

Hi,
New to creating plugins and just after a little help.

Have created my xml installation file and my plugin php file and all works as expected.

Also created my tmpl/default.php which all works, but from this file I need to be able to access $this->product->product_box but I cannot seem to get this to work,

I am using boxQ = '.$this->product->product_box.';

Any help would be much appreciated!

Thanks


Using Joomla! 3.10.11 and VirtueMart 3.8.7


GJC Web Design

QuoteboxQ = '.$this->product->product_box.';

is there anything set for $this->product->product_box?

print 'Debug Line '.__LINE__.' $this->product <pre>'; print_r ($this->product); print "</pre><br />\n";

as for the syntax ... echo 'boxQ = '.$this->product->product_box; is that what u mean?

or

$boxQ = $this->product->product_box;
echo $boxQ;

hard to know what your trying to display...
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Picklehead

Thanks for the reply!

Yes, under Product Dimensions and Weight i have a value for Units in Box for all products.

My default.php adds a single input box on the product details page as a custom field and on keyup a function is called. I am simply trying to use the value of the product Units In Box for calculations within this function.

I have added an extra field to the params of my plugin as a temporary holder for a Units in Box value to test my calculations and all works exactly as I want.

I just need to avoid having to enter a Units in Box value into the custom field for all products when it already exists on each product

Hope that makes sense.

Thanks again

Picklehead

#3
Chopped abbreviated version of the function


$j = 'function setQuantity(myElem,inVal,sVal){

if(sVal > 0.0){
    quantity = Math.ceil(inVal/sVal);
    tempQuant = Math.ceil(quantity / '.$this->params->in_box.');
    tempOut = tempQuant * '.$this->params->in_box.'
    quantity = tempOut;
outQuant = quantity * sVal ;
}

myElem.val(outQuant);

return true;
};


Where '.$this->params->in_box.' needs to be the value of $this->product->product_box

Picklehead

Thanks for the help, I found this worked for me.


$productModel = VmModel::getModel('Product');
$product = $productModel->getProduct($viewData[1]->virtuemart_product_id);