Author Topic: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5  (Read 76740 times)

crisware

  • Beginner
  • *
  • Posts: 11
Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
« Reply #150 on: October 04, 2012, 13:22:29 pm »
I like Virtuemart 1.1 and Joomla 1.5 and I use them for years. Although I tried to upgrade to VM 2 but also it is not include multiple choice custom fields (checkboxes or multilists). I am very disappointed with that and I cannot understand why they don't include that feature in their script. Many people need it but unfortunately nobody from VM developers seems to mind...

Anyway!

Thank you for your help!

Since last year I use your extension in older versions of VM and I REALLY love it!!!!!

webgobe

  • Advanced
  • Full Member
  • *****
  • Posts: 535
  • Follow me on Twitter! http://twitter.com/webgobe
    • Internet craftsman carrying on the heritage of European manufacturing traditions through original Web designs.
Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
« Reply #151 on: October 04, 2012, 13:39:49 pm »
I also still use Joomla 1.5 EXCLUSIVELY because VM 1.9 runs uder that  - so I know your feelings :)
Like a fine wine... Good from the start and getting better over time.
Donations are welcome!

crisware

  • Beginner
  • *
  • Posts: 11
Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
« Reply #152 on: October 04, 2012, 14:28:21 pm »
BTW I think I have found the BUG and I Fixed it...

in ps_product.php you must change this (line about 1914):

Code: [Select]
for($i=0; $i < sizeof($attribute_keys); $i++ ) {
$temp_desc = $attribute_keys[$i];

$temp_desc = trim( $temp_desc );
// Get the key name (e.g. "Color" )
$this_key = substr( $temp_desc, 0, strpos($temp_desc, ":") );
$this_value = substr( $temp_desc, strpos($temp_desc, ":")+1 );
$this_value = addslashes( $this_value ); // since advanced attribute values are saved quote-escaped in db, we should give a similar string

if( in_array( $this_key, $custom_attribute_fields )) {
if( @$custom_attribute_fields_check[$this_key] == md5( $mosConfig_secret.$this_key )) {
// the passed value is valid, don't use it for calculating prices
continue;
}
}
               
if( isset( $product_attributes[$this_key]['values'][$this_value] )) {
$modifier = $product_attributes[$this_key]['values'][$this_value]['adjustment'];
$operand = $product_attributes[$this_key]['values'][$this_value]['operand'];

// if we have a number, allow the adjustment
if (true == is_numeric($modifier) ) {
                   
// Now add or sub the modifier on
if ($operand=="+") {
$adjustment += $modifier;
}
else if ($operand=="-") {
$adjustment -= $modifier;
}
else if ($operand=='=') {
// NOTE: the +=, so if we have 2 sets they get added
// this could be moded to say, if we have a set_price, then
// calc the diff from the base price and start from there if we encounter
// another set price... just a thought.

$setprice += $modifier;
$set_price = true;
}
}
} else {
continue;
}
}
}

to this:

Code: [Select]
for($i=0; $i < sizeof($attribute_keys); $i++ ) {
$temp_desc = $attribute_keys[$i];

$temp_desc_keys = explode( ",", $temp_desc );
foreach ($temp_desc_keys as $temp_desc){

$temp_desc = trim( $temp_desc );
// Get the key name (e.g. "Color" )
if(strpos($temp_desc, ":")){
$this_key = substr( $temp_desc, 0, strpos($temp_desc, ":") );
$this_value = substr( $temp_desc, strpos($temp_desc, ":")+1 );
} else {
    $this_key = $this_key;
$this_value = $temp_desc;
}

if( in_array( $this_key, $custom_attribute_fields )) {
if( @$custom_attribute_fields_check[$this_key] == md5( $mosConfig_secret.$this_key )) {
// the passed value is valid, don't use it for calculating prices
continue;
}
}
               
$this_value=str_replace("_"," ",$this_value);
if( !isset( $product_attributes[$this_key]['values'][$this_value] )) {
$this_true_value = $this_value;
$this_value = 'vm_charge';
}
if( isset( $product_attributes[$this_key]['values'][$this_value] )) {
$modifier = $product_attributes[$this_key]['values'][$this_value]['adjustment'];
$operand = $product_attributes[$this_key]['values'][$this_value]['operand'];
if($this_value == 'vm_charge'){
$this_value = this_true_value;
}
// if we have a number, allow the adjustment
if (true == is_numeric($modifier) ) {
                   
$modifier = $GLOBALS['CURRENCY']->convert( $modifier, $price['product_currency'], $GLOBALS['product_currency'] );
// Now add or sub the modifier on
if ($operand=="+") {
$adjustment += $modifier;
}
else if ($operand=="-") {
$adjustment -= $modifier;
}
else if ($operand=='=') {
// NOTE: the +=, so if we have 2 sets they get added
// this could be moded to say, if we have a set_price, then
// calc the diff from the base price and start from there if we encounter
// another set price... just a thought.

$setprice += $modifier;
$set_price = true;
}
}
} else {
continue;
}
}
}
}


and this (line about 2111):

Code: [Select]
foreach( $attribute_keys as $temp_desc ) {
$finish = strpos($temp_desc,"]");
$temp_desc = trim( $temp_desc );
// Get the key name (e.g. "Color" )
$this_key = substr( $temp_desc, 0, strpos($temp_desc, ":") );
$this_value = substr( $temp_desc, strpos($temp_desc, ":")+1 );

if( in_array( $this_key, $custom_attribute_fields )) {
if( @$custom_attribute_fields_check[$this_key] == md5( $mosConfig_secret.$this_key )) {
// the passed value is valid, don't use it for calculating prices
continue;
}
}
           
if( isset( $product_attributes[$this_key]['values'][$this_value] )) {
$modifier = $product_attributes[$this_key]['values'][$this_value]['adjustment'];
$operand = $product_attributes[$this_key]['values'][$this_value]['operand'];

$value_notax = $GLOBALS['CURRENCY']->convert( $modifier, $product_currency );
if( abs($value_notax) >0 ) {
$value_taxed = $value_notax * ($my_taxrate+1);
/* modified by JK for fixing incorrect values matching
$temp_desc_new  = str_replace( $operand.$modifier, $operand.' '.$CURRENCY_DISPLAY->getFullValue( $value_taxed ), $temp_desc );
                    $description = str_replace( $this_key.':'.$this_value,
$this_key.':'.$this_value.' ('.$operand.' '.$CURRENCY_DISPLAY->getFullValue( $value_taxed ).')',
$description); */
        $temp_desc_new  = str_replace( $this_value, $this_value . ' (' . $operand.' '.$CURRENCY_DISPLAY->getFullValue( $value_taxed ).')', $temp_desc );
$description = str_replace( $temp_desc, $temp_desc_new, $description);

}
//$temp_desc = substr($temp_desc, $finish+1);
}

}


to this:

Code: [Select]

foreach( $attribute_keys as $temp_desc ) {
$temp_desc_keys = explode( ",", $temp_desc );
foreach ($temp_desc_keys as $temp_desc){
$finish = strpos($temp_desc,"]");
$temp_desc = trim( $temp_desc );
// Get the key name (e.g. "Color" )
if(strpos($temp_desc, ":")){
$this_key = substr( $temp_desc, 0, strpos($temp_desc, ":") );
$this_value = substr( $temp_desc, strpos($temp_desc, ":")+1 );
} else {
//$temp_desc .= $this_key.':'.$temp_desc;
$this_key = $this_key;
$this_value = $temp_desc;
}
if( in_array( $this_key, $custom_attribute_fields )) {
if( @$custom_attribute_fields_check[$this_key] == md5( $mosConfig_secret.$this_key )) {
// the passed value is valid, don't use it for calculating prices
continue;
}
}

            $this_value = str_replace("_"," ",$this_value);
if( !isset( $product_attributes[$this_key]['values'][$this_value] )) {
$this_true_value = $this_value;
$this_value = 'vm_charge';
}
if( isset( $product_attributes[$this_key]['values'][$this_value] )) {
$modifier = $product_attributes[$this_key]['values'][$this_value]['adjustment'];
$operand = $product_attributes[$this_key]['values'][$this_value]['operand'];
if($this_value == 'vm_charge'){
$this_value = $this_true_value;
}
$value_notax = $modifier;
if( abs($value_notax) >0 ) {
$value_taxed = $value_notax * ($my_taxrate+1);
// modified by JK for fixing incorrect values matching
// $temp_desc_new  = str_replace( $operand.$modifier, $operand.' '.$CURRENCY_DISPLAY->getFullValue( $value_taxed ), $temp_desc );
// $description = str_replace( $this_value,
// $this_value.' ('.$operand.' '.$CURRENCY_DISPLAY->getFullValue( $value_taxed ).')',
// $description);

$temp_desc_new  = str_replace( $this_value, $this_value . ' (' . $operand.' '.$CURRENCY_DISPLAY->getFullValue( $value_taxed ).')', $temp_desc );
$description = str_replace( $temp_desc, $temp_desc_new, $description);
}
//$temp_desc = substr($temp_desc, $finish+1);
}
}
}



Also I removed this (line 2910) as it had problems:

Code: [Select]
// Check if there is an extended class in the Themes and if it is allowed to use them
// If the class is called outside Virtuemart, we have to make sure to load the settings
// Thomas Kahl - Feb. 2009
if (!defined('VM_ALLOW_EXTENDED_CLASSES') && file_exists(dirname(__FILE__).'/../virtuemart.cfg.php')) {
include_once(dirname(__FILE__).'/../virtuemart.cfg.php');
}
// If settings are loaded, extended Classes are allowed and the class exisits...
if (defined('VM_ALLOW_EXTENDED_CLASSES') && defined('VM_THEMEPATH') && VM_ALLOW_EXTENDED_CLASSES && file_exists(VM_THEMEPATH.'user_class/'.basename(__FILE__))) {
// Load the theme-user_class as extended
include_once(VM_THEMEPATH.'user_class/'.basename(__FILE__));
} else {
// Otherwise we have to use the original classname to extend the core-class
class ps_product extends vm_ps_product {}
}

PolishedGeek

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 263
  • Joomla! Innovation Refined.
    • Polished Geek, LLC - Joomla! extensions, web development & custom integrations
Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
« Reply #153 on: October 04, 2012, 15:46:06 pm »
For those who need more advanced custom fields and attributes for VM2, you might want to look into integrating a custom designed form in your products to handle complex attributes and dependent options. We're still accepting interested beta testers who have good use cases for this type of functionality -  http://forum.virtuemart.net/index.php?topic=107973.msg362481#msg362481
~ Deb Cinkus, CEO
Polished Geek, LLC   |    www.PolishedGeek.com

Creators of JoomLister - eBay Lister for Joomla!

webgobe

  • Advanced
  • Full Member
  • *****
  • Posts: 535
  • Follow me on Twitter! http://twitter.com/webgobe
    • Internet craftsman carrying on the heritage of European manufacturing traditions through original Web designs.
Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
« Reply #154 on: October 04, 2012, 16:40:57 pm »
@crisware: will test it, and eventually include it in the pack. Thanks!
Like a fine wine... Good from the start and getting better over time.
Donations are welcome!

flaszlo

  • Beginner
  • *
  • Posts: 1
Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
« Reply #155 on: October 19, 2012, 13:42:28 pm »
Hi,

I need some help about CAE.

I found a strange behaviour: right after I add a product to the cart it uses good prices (sum of all options price), but after a refresh it loses its prices, and it calculates just with the base price.

After several hours we found that the $_SESSION['cart']['extra_charge'] loses its values somehow. Do you have any idea to find a solution?

Best regards,

Cheers,

Laszlo

webgobe

  • Advanced
  • Full Member
  • *****
  • Posts: 535
  • Follow me on Twitter! http://twitter.com/webgobe
    • Internet craftsman carrying on the heritage of European manufacturing traditions through original Web designs.
Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
« Reply #156 on: October 19, 2012, 16:19:59 pm »
If that is indeed what you are loosing, then this is not a CAE specific problem. CAE just piggybacks on the existing custom attributes mechanisms built in the VM core, extending it's usefulness. Ne new variable storage or handling techniques are used. So it's probably something with your concrete setup, not the hack itself. But I am curious to see your site and to find and eventually fix the bug.
Like a fine wine... Good from the start and getting better over time.
Donations are welcome!

timkolm

  • Beginner
  • *
  • Posts: 40
Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
« Reply #157 on: October 20, 2012, 21:53:51 pm »
Hi Webgobe,
What would you suggest if I wish to find a way to affect the weight of a selected product according to the area (and some other options) selected? I need it for the shipping module to calculate the shipping-price correctly. Maybe to create some new global variable to pass it to a special shipping module which will handle it?... Or i can use the standard shipping module and only pass a temporarily changed weight variable to it???.
What would you do?

webgobe

  • Advanced
  • Full Member
  • *****
  • Posts: 535
  • Follow me on Twitter! http://twitter.com/webgobe
    • Internet craftsman carrying on the heritage of European manufacturing traditions through original Web designs.
Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
« Reply #158 on: October 22, 2012, 10:26:48 am »
I would try to overwrite the weight in the cart. Sounds the simplest way to do it, and I think can be done relatively easily by extending the hack a bit.
Like a fine wine... Good from the start and getting better over time.
Donations are welcome!

leorobles

  • Beginner
  • *
  • Posts: 14
Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
« Reply #159 on: October 25, 2012, 23:47:58 pm »
You always helped me and now it's time to help you, have you seen this? VM 1.2 (VM 1.1.9 is for Joomla 2.5)
The link is below:
http://joomlacode.org/gf/project/vm11j25/frs/
The latest version of your hack is CAE9.zip?
Hugs and thanks.

timkolm

  • Beginner
  • *
  • Posts: 40
Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
« Reply #160 on: December 22, 2012, 16:46:59 pm »
One more question. Can i make the attribute description in the cart to be in several lines, i.e. use a <br/> tag? So that it would be like that:

Item name
Attribute:
Description line1
Description line2
Description line3
Description line....

webgobe

  • Advanced
  • Full Member
  • *****
  • Posts: 535
  • Follow me on Twitter! http://twitter.com/webgobe
    • Internet craftsman carrying on the heritage of European manufacturing traditions through original Web designs.
Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
« Reply #161 on: December 22, 2012, 17:22:55 pm »
Good question. Short answer: maybe. Longer one - better avoid to place there any kind of code - even HTML code, since the attributes are handled by the VM cart code, it's dangerous attempt. After Xmas I might have the time to look for a possible (and foolproof) solution for you, but I am not sure that can be easily done.
Like a fine wine... Good from the start and getting better over time.
Donations are welcome!

timkolm

  • Beginner
  • *
  • Posts: 40
Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
« Reply #162 on: January 29, 2013, 14:27:44 pm »
What file is responsible for the tip text of attributes? I want to implement some layout in there. Can I?

webgobe

  • Advanced
  • Full Member
  • *****
  • Posts: 535
  • Follow me on Twitter! http://twitter.com/webgobe
    • Internet craftsman carrying on the heritage of European manufacturing traditions through original Web designs.
Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
« Reply #163 on: January 29, 2013, 14:37:23 pm »
It is in  one of core VM files - can't remember right now, as I arrive home, will check it for you.
Like a fine wine... Good from the start and getting better over time.
Donations are welcome!

webgobe

  • Advanced
  • Full Member
  • *****
  • Posts: 535
  • Follow me on Twitter! http://twitter.com/webgobe
    • Internet craftsman carrying on the heritage of European manufacturing traditions through original Web designs.
Re: Converted Custom Attributes Extended Hack 3.0 for VM 1.1 + J1.5
« Reply #164 on: January 29, 2013, 17:07:38 pm »
function customAttributeHTML from ps_product_custom_attribute.php, is inherited from core ps_product_attribute.php
Like a fine wine... Good from the start and getting better over time.
Donations are welcome!