Link im Warenkorb zurück zur Produkt

The problem: After a product is added to the shopping cart, it is linked in the cart view to the location from which it was added to the cart. In other words, if the product is added from an overview page, that overview page is linked instead of the actual product page.

One approach is to modify the MyReferer input field and use it to pass the respective product link, or the link to the post containing the product, to the target page via the form and $_REQUEST['MyReferer']. This can be achieved in three steps:


1) Delete the following assignment
$strReturn_Gesamt .= '<input type="hidden" name="myReferer" value="'.htmlspecialchars($myReferer).'" />';
from wp-content\plugins\wpshopgermany\controllers\WarenkorbController.class.php.

2) Modify the assignment of the "referer" variable in the classes of the wpShopGermany modules being used. For example, in \wp-content\plugins\wpshopgermany\mods\mod_variantenplus.class.php, replace
$_SESSION['wpshopgermany']['basket'][intval($_REQUEST['produkt'])]['vari'][$var_key] = array( "v_id" => $_REQUEST['produkt']."/".$var_key, "menge" => intval($_REQUEST['menge']), "referer" => $_SERVER['HTTP_REFERER']);
with
$_SESSION['wpshopgermany']['basket'][intval($_REQUEST['produkt'])]['vari'][$var_key] = array( "v_id" => $_REQUEST['produkt']."/".$var_key, "menge" => intval($_REQUEST['menge']), "referer" => $_REQUEST['myReferer']);

3) Add the MyReferer input field to the form at the relevant locations. For example, when using the WordPress plugin "Posts for Page", this can be done in wp-content\plugins\posts-for-page\posts-for-page.php using the str_replace command, or directly in the template using instructions such as:
$content = get_the_content();
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
$content = str_replace('<div class="wpshopgermany">', "<input type='hidden' name='myReferer' value='".get_permalink()."' /><div class='wpshopgermany'>",$content);

... back to the blog