hey i have a problem with minishop2. I want the clicked values in “msProduct.content” to be sent as an e-mail.
However, only the article numbers, the price and the weight are transmitted. Unfortunately not the size.
Sending the mail is not a problem. However, the “size” value is not transmitted.
I did it with the button like this:
have anyone any idea how i can fix it ?
Thank you all!
antar
September 1, 2021, 7:28am
2
Hi @Rykoutech ,
as you can see in msProduct.content
additional snippet is used for size
option, this isn’t a basic one but additional.
[[msOptions?options=`color,size`]]
Please check tpl.msOptions
chunk is used by msOptions
, you should have a similar approach in your’s email body.
Hey @himurovich , thanks for your quick reply.
There is no tpl.msOptions in msOptions.
This is not included by default, is it?
Oh sorry, it is used in msOptions…
and
[[msOptions?options=color,size
]]
is used in msProduct.content
This is what it looks like in the button code *
hey, and the msOption Snippet Looks like that:
$miniShop2 = $modx->getService(‘miniShop2’);
$tpl = $modx->getOption(‘tpl’, $scriptProperties, ‘tpl.msOptions’);
if (!empty($input) && empty($product)) {
$product = $input;
}
if (!empty($name) && empty($options)) {
$options = $name;
}
$product = !empty($product) && $product != $modx->resource->id
? $modx->getObject(‘msProduct’, array(‘id’ => $product))
: $modx->resource;
if (!($product instanceof msProduct)) {
return “[msOptions] The resource with id = {$product->id} is not instance of msProduct.”;
}
$names = array_map(‘trim’, explode(‘,’, $options));
$options = array();
foreach ($names as $name) {
if (!empty($name) && $option = $product->get($name)) {
if (!is_array($option)) {
$option = array($option);
}
if (isset($option[0]) and (trim($option[0]) != ‘’)) {
$options[$name] = $option;
}
}
}
$options = $miniShop2->sortOptionValues($options, $scriptProperties[‘sortOptionValues’]);
/** @var pdoTools $pdoTools */
$pdoTools = $modx->getService(‘pdoTools’);
return $pdoTools->getChunk($tpl, array(
‘id’ => $product->id,
‘options’ => $options,
));
antar
September 1, 2021, 8:48am
7
Do you use fenom? if so this might happen for your link(or custom snippet for more compact view):
<a href = "mailto: Example@mail.com? Subject = Product request <Artikel Nummer: [[+ article]], {foreach $options as $option}{if $option.caption is 'size'}{$option.value}{/if}{/foreach}, [[+ weight ]] Kg> "> Produktanfrage </a>
I’m already a bit desperate it never works the way I want it … I just wonder why the link doesn’t take on the value of [[+size]].
antar
September 1, 2021, 9:43am
10
Please create next custom snippet and call it somewhere on your page:
$resourceID = $modx->resource->id;
$desiredOptionKey = 'size';
$product = $modx->getObject('msProduct', array(
'id' => $resourceID
));
$options = $product->getMany('Options');
foreach ($options as $dataKey => $dataValue) {
if ($dataKey == $desiredOptionKey) {
$modx->setPlaceholder("product_size", $dataValue); // or maybe $dataValue[0], please clarify this using print_r($dataValue)
}
}
and after
<a href = "mailto: Example@mail.com? Subject = Product request <Artikel Nummer: [[+article]], [[+product_size]], [[+weight]] Kg> "> Produktanfrage </a>
I have now created a new snippet with the content called “Product_size”. Then I added the snippet to msProduct.content and adjusted the link. But unfortunately it only shows me error messages when I reload the page.
antar
September 1, 2021, 1:07pm
13
Do you use this snippet on the product page? Could you please send here the errors you’ve got?
Hey, yes, I used it for the msProduct.content chunk.
Because my customer suddenly no longer needs the function But i thank you so much for your help!