Bonjour,
je vous contacte car j'ai acheté en avril un module de recommande pour virtuemart qui maintenant est devenu gratuit et donc sans support comme précisé sur le site du fournisseur de module. Je me retrouve coincé surtout que je dois déployer cette semaine et que c'est une fonctionnalité majeur de mon site.
Le module fonctionne globalement bien mais je me retrouve avec un bug lorsque mes produits ont des custom fields de type plugin drop.
En effet, il ne sont pas recopiés dans le caddy, ce qui fait que je perds les informations intéressantes.
J'ai exploré le code sans trouver la solution. Peut-être aurez vous une solution en regardant les extraits de code du module ci-dessous :
defaut.php:
if(isset($products) && is_array($products) && count($products) > 0){
?>
<div class="vmReorderModule <?php echo $moduleclass_sfx; ?>" id="vmReorderModule">
<form method="post" class="product js-recalculate" action="index.php" id="vmReorderModuleForm">
<p><?php echo $pretext; ?></p>
<div class="addtocart-bar">
<span class="addtocart-button">
<input type="submit" name="addtocart" class="addtocart-button" value="<?php echo $buttontext; ?>" title="<?php echo $buttontext; ?>">
</span>
</div>
<?php
// Product custom_fields
if (!empty($product->custom_attributes)) {
?>
<div class="product-fields">
<?php foreach ($product->custom_attributes as $field) { ?>
<div style="display:inline-block;" class="product-field product-field-type-<?php echo $field->field_type ?>">
<?php if($field->show_title == 1) { ?>
<span class="product-fields-title"><b><?php echo $field->custom_title ?></b></span>
<?php echo JHTML::tooltip ($field->custom_tip, $field->custom_title, 'tooltip.png'); ?>
<?php } ?>
<span class="product-field-display"><?php echo $field->display ?></span>
<span class="product-field-desc"><?php echo $field->custom_field_desc ?></span>
</div>
<?php } ?>
</div>
<?php } ?>
<?php
foreach($products as $key => $product){
$addToCartUrl = JURI::root().'?option=com_virtuemart&controller=ca rt&task=addJS&virtuemart_product_id[]='.$product->virtuemart_product_id.'&quantity[]='.$product->product_quantity;
// echo "<pre>";var_dump($product);echo "</pre>";
if(is_array($product->attributes) && count($product->attributes) > 0)
{
foreach($product->attributes as $attribute)
{
$addToCartUrl .= '&customPrice['.$key.']['.$attribute->custom_id.']='.$attribute->id;;
?>
<input type="hidden" name="customPrice[<?php echo $key; ?>][<?php echo $attribute->custom_id; ?>]" value="<?php echo $attribute->id; ?>">
<?php
}
}
?>
<input type="hidden" name="quantity[]" value="<?php echo $product->product_quantity; ?>">
<input type="hidden" name="virtuemart_product_id[]" value="<?php echo $product->virtuemart_product_id; ?>">
<input type="hidden" name="reorderUrl" class="reorderUrl" value="<?php echo $addToCartUrl; ?>">
<?php } ?>
<input type="hidden" name="option" value="com_virtuemart">
<input type="hidden" name="view" value="cart">
<input type="hidden" name="task" value="add">
<input type="hidden" name="virtuemart_manufacturer_id" value="Array">
</form>
</div>
<script type="text/javascript">
// if jQuery isn't loaded, load it.
if (typeof jQuery == 'undefined') {
function getScript(url, success) {
var script = document.createElement('script');
script.src = url;
var head = document.getElementsByTagName('head')[0],
done = false;
// Attach handlers for all browsers
script.onload = script.onreadystatechange = function() {
if (!done && (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete')) {
done = true;
success();
script.onload = script.onreadystatechange = null;
head.removeChild(script);
};
};
head.appendChild(script);
};
getScript('http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js');
}
// jQuery was already loaded
jQuery('#vmReorderModuleForm').submit(function(eve nt){
event.preventDefault();
var productToReorder = jQuery('.reorderUrl');
var productCount = productToReorder.length;
var productCounter = 0;
jQuery('.reorderUrl').each(function(){
var productUrl = jQuery(this).val();
jQuery.ajax({
url: productUrl,
async: false,
context: document.body,
success: function(resultData){
var result = jQuery.parseJSON(resultData);
productCounter++;
jQuery('#vmReorderModule').append('<div class="alert alert-success">'+result.msg+'<div>');
if(productCounter == productCount){
window.location.href = "<?php echo JURI::root() ?>?option=com_virtuemart&view=cart";
}
}
});
});
});
</script>
<?php }
mod_....php :
if (!class_exists( 'mod_virtuemart_reorder' )) require('helper.php');
$orderNumber = JRequest::getVar('order_number');
if($orderNumber)
{
$helper = new mod_virtuemart_reorder();
$order = $helper->getOrderProducts($orderNumber);
$products = $order['items'];
$custom_attributes = json_decode($product->customPlugin);
// echo "<pre>";var_dump($products);echo "</pre>";
foreach($products as $pkey => $product)
{
$attributes = (array)json_decode($product->product_attribute);
if(is_array($attributes) && count($attributes) > 0)
{
$products[$pkey]->attributes = array();
foreach($attributes as $key => $attr)
{
$attr = explode('</span>', $attr);
$attribute = new stdClass();
$attribute->id = $key;
$attribute->name = trim(strip_tags($attr[0]));
$attribute->value = trim(strip_tags($attr[1]));
$attribute->custom_id = $helper->getCustomIdByTitle($attribute->name);
$products[$pkey]->attributes[] = $attribute;
}
}
}
$pretext = $params->get('pretext', '');
$buttontext = $params->get('buttontext', '');
$moduleclass_sfx = $params->get('moduleclass_sfx', '');
require(JModuleHelper::getLayoutPath('mod_virtuema rt_reorder'));
}
Mon joomla : 2.5.27
Mon virtuemart : 2.6.18
- - - Mise à jour - - -
Merci par avance
je vous contacte car j'ai acheté en avril un module de recommande pour virtuemart qui maintenant est devenu gratuit et donc sans support comme précisé sur le site du fournisseur de module. Je me retrouve coincé surtout que je dois déployer cette semaine et que c'est une fonctionnalité majeur de mon site.
Le module fonctionne globalement bien mais je me retrouve avec un bug lorsque mes produits ont des custom fields de type plugin drop.
En effet, il ne sont pas recopiés dans le caddy, ce qui fait que je perds les informations intéressantes.
J'ai exploré le code sans trouver la solution. Peut-être aurez vous une solution en regardant les extraits de code du module ci-dessous :
defaut.php:
if(isset($products) && is_array($products) && count($products) > 0){
?>
<div class="vmReorderModule <?php echo $moduleclass_sfx; ?>" id="vmReorderModule">
<form method="post" class="product js-recalculate" action="index.php" id="vmReorderModuleForm">
<p><?php echo $pretext; ?></p>
<div class="addtocart-bar">
<span class="addtocart-button">
<input type="submit" name="addtocart" class="addtocart-button" value="<?php echo $buttontext; ?>" title="<?php echo $buttontext; ?>">
</span>
</div>
<?php
// Product custom_fields
if (!empty($product->custom_attributes)) {
?>
<div class="product-fields">
<?php foreach ($product->custom_attributes as $field) { ?>
<div style="display:inline-block;" class="product-field product-field-type-<?php echo $field->field_type ?>">
<?php if($field->show_title == 1) { ?>
<span class="product-fields-title"><b><?php echo $field->custom_title ?></b></span>
<?php echo JHTML::tooltip ($field->custom_tip, $field->custom_title, 'tooltip.png'); ?>
<?php } ?>
<span class="product-field-display"><?php echo $field->display ?></span>
<span class="product-field-desc"><?php echo $field->custom_field_desc ?></span>
</div>
<?php } ?>
</div>
<?php } ?>
<?php
foreach($products as $key => $product){
$addToCartUrl = JURI::root().'?option=com_virtuemart&controller=ca rt&task=addJS&virtuemart_product_id[]='.$product->virtuemart_product_id.'&quantity[]='.$product->product_quantity;
// echo "<pre>";var_dump($product);echo "</pre>";
if(is_array($product->attributes) && count($product->attributes) > 0)
{
foreach($product->attributes as $attribute)
{
$addToCartUrl .= '&customPrice['.$key.']['.$attribute->custom_id.']='.$attribute->id;;
?>
<input type="hidden" name="customPrice[<?php echo $key; ?>][<?php echo $attribute->custom_id; ?>]" value="<?php echo $attribute->id; ?>">
<?php
}
}
?>
<input type="hidden" name="quantity[]" value="<?php echo $product->product_quantity; ?>">
<input type="hidden" name="virtuemart_product_id[]" value="<?php echo $product->virtuemart_product_id; ?>">
<input type="hidden" name="reorderUrl" class="reorderUrl" value="<?php echo $addToCartUrl; ?>">
<?php } ?>
<input type="hidden" name="option" value="com_virtuemart">
<input type="hidden" name="view" value="cart">
<input type="hidden" name="task" value="add">
<input type="hidden" name="virtuemart_manufacturer_id" value="Array">
</form>
</div>
<script type="text/javascript">
// if jQuery isn't loaded, load it.
if (typeof jQuery == 'undefined') {
function getScript(url, success) {
var script = document.createElement('script');
script.src = url;
var head = document.getElementsByTagName('head')[0],
done = false;
// Attach handlers for all browsers
script.onload = script.onreadystatechange = function() {
if (!done && (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete')) {
done = true;
success();
script.onload = script.onreadystatechange = null;
head.removeChild(script);
};
};
head.appendChild(script);
};
getScript('http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js');
}
// jQuery was already loaded
jQuery('#vmReorderModuleForm').submit(function(eve nt){
event.preventDefault();
var productToReorder = jQuery('.reorderUrl');
var productCount = productToReorder.length;
var productCounter = 0;
jQuery('.reorderUrl').each(function(){
var productUrl = jQuery(this).val();
jQuery.ajax({
url: productUrl,
async: false,
context: document.body,
success: function(resultData){
var result = jQuery.parseJSON(resultData);
productCounter++;
jQuery('#vmReorderModule').append('<div class="alert alert-success">'+result.msg+'<div>');
if(productCounter == productCount){
window.location.href = "<?php echo JURI::root() ?>?option=com_virtuemart&view=cart";
}
}
});
});
});
</script>
<?php }
mod_....php :
if (!class_exists( 'mod_virtuemart_reorder' )) require('helper.php');
$orderNumber = JRequest::getVar('order_number');
if($orderNumber)
{
$helper = new mod_virtuemart_reorder();
$order = $helper->getOrderProducts($orderNumber);
$products = $order['items'];
$custom_attributes = json_decode($product->customPlugin);
// echo "<pre>";var_dump($products);echo "</pre>";
foreach($products as $pkey => $product)
{
$attributes = (array)json_decode($product->product_attribute);
if(is_array($attributes) && count($attributes) > 0)
{
$products[$pkey]->attributes = array();
foreach($attributes as $key => $attr)
{
$attr = explode('</span>', $attr);
$attribute = new stdClass();
$attribute->id = $key;
$attribute->name = trim(strip_tags($attr[0]));
$attribute->value = trim(strip_tags($attr[1]));
$attribute->custom_id = $helper->getCustomIdByTitle($attribute->name);
$products[$pkey]->attributes[] = $attribute;
}
}
}
$pretext = $params->get('pretext', '');
$buttontext = $params->get('buttontext', '');
$moduleclass_sfx = $params->get('moduleclass_sfx', '');
require(JModuleHelper::getLayoutPath('mod_virtuema rt_reorder'));
}
Mon joomla : 2.5.27
Mon virtuemart : 2.6.18
- - - Mise à jour - - -
Merci par avance
Commentaire