Hallo,
Voor een project maak ik gebruik van de Wordpress plugin: Spreadplugin.
Nu wil ik graag een eigen "winkelwagen pagina" maken, in plaats van de popup die standaard gebruikt wordt bij de plugin. Omdat ik hier graag een aparte pagina voor wil, heb ik een wordpress page-template gemaakt. Echter loop ik nu tegen 1 probleem aan.
Als ik de file include waarin de functie die de inhoud van het winkelmandje laat zien geladen wordt, dan laad hij de header en footer van mijn Wordpress thema niet meer.
Kan iemand mij hier mee verder helpen? Of heeft iemand een idee hoe dit kan?
Hieronder de codes 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/**
* This template displays the articles in your basket.
*
* Author: Jeffrey van Dijk
* Release: 1.0
*
* Template Name: Cart
*/
get_header(); ?>
while ( have_posts() ) : the_post(); ?>
get_template_part( content, page ); ?>
->doCart();?>
endwhile; // end of the loop. ?>
get_footer(); ?>
Klein stukje van de spreadplugin file (voor de hele file, pb me even) 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// build cart
public function doCart() {
//if (!wp_verify_nonce($_GET[nonce], spreadplugin)) die(Security check);
$this->reparseShortcodeData();
// overwrite translation if language available and set
if (!empty(self::$shopOptions[shop_language])) {
$_ol = dirname(__FILE__) . /translation/ . $this->stringTextdomain . - . self::$shopOptions[shop_language] . .mo;
if (file_exists($_ol)) {
load_textdomain($this->stringTextdomain, $_ol);
}
} else {
load_plugin_textdomain($this->stringTextdomain, false, dirname(plugin_basename(__FILE__)) . /translation);
}
// create an new basket if not exist
if (isset($_SESSION[basketUrl][self::$shopOptions[shop_source] . self::$shopOptions[shop_language]])) {
$basketItems = self::getBasket($_SESSION[basketUrl][self::$shopOptions[shop_source] . self::$shopOptions[shop_language]]);
$priceSum = 0;
$intSumQuantity = 0;
echo
echo
if ($intSumQuantity > 0) {
echo
} else {
echo
}
}
die();
}
// delete cart
public function doCartItemDelete() {
//if (!wp_verify_nonce($_GET[nonce], spreadplugin)) die(Security check);
$this->reparseShortcodeData();
// create an new basket if not exist
if (isset($_SESSION[basketUrl][self::$shopOptions[shop_source] . self::$shopOptions[shop_language]])) {
// uuid test
if (preg_match(/w{8}-w{4}-w{4}-w{4}-w{12}/, $_POST[id])) {
self:SMILEYYYYYYYYYYYBEGIN:deleteBasketItem($_SESSION[basketUrl][self::$shopOptions[shop_source] . self::$shopOptions[shop_language]], $_POST[id]);
}
}
die();
}
Voor een project maak ik gebruik van de Wordpress plugin: Spreadplugin.
Nu wil ik graag een eigen "winkelwagen pagina" maken, in plaats van de popup die standaard gebruikt wordt bij de plugin. Omdat ik hier graag een aparte pagina voor wil, heb ik een wordpress page-template gemaakt. Echter loop ik nu tegen 1 probleem aan.
Als ik de file include waarin de functie die de inhoud van het winkelmandje laat zien geladen wordt, dan laad hij de header en footer van mijn Wordpress thema niet meer.
Kan iemand mij hier mee verder helpen? Of heeft iemand een idee hoe dit kan?
Hieronder de codes
(template-cart.php)
Codeblok (template-cart.php):
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/**
* This template displays the articles in your basket.
*
* Author: Jeffrey van Dijk
* Release: 1.0
*
* Template Name: Cart
*/
get_header(); ?>
while ( have_posts() ) : the_post(); ?>
get_template_part( content, page ); ?>
->doCart();?>
endwhile; // end of the loop. ?>
get_footer(); ?>
Klein stukje van de spreadplugin file (voor de hele file, pb me even)
(spreadplugin.php)
Codeblok (spreadplugin.php):
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// build cart
public function doCart() {
//if (!wp_verify_nonce($_GET[nonce], spreadplugin)) die(Security check);
$this->reparseShortcodeData();
// overwrite translation if language available and set
if (!empty(self::$shopOptions[shop_language])) {
$_ol = dirname(__FILE__) . /translation/ . $this->stringTextdomain . - . self::$shopOptions[shop_language] . .mo;
if (file_exists($_ol)) {
load_textdomain($this->stringTextdomain, $_ol);
}
} else {
load_plugin_textdomain($this->stringTextdomain, false, dirname(plugin_basename(__FILE__)) . /translation);
}
// create an new basket if not exist
if (isset($_SESSION[basketUrl][self::$shopOptions[shop_source] . self::$shopOptions[shop_language]])) {
$basketItems = self::getBasket($_SESSION[basketUrl][self::$shopOptions[shop_source] . self::$shopOptions[shop_language]]);
$priceSum = 0;
$intSumQuantity = 0;
echo
;
if (!empty($basketItems)) {
//echo "
foreach ($basketItems->basketItems->basketItem as $item) {
if ((string)$item->element[type] == sprd:product) {
// Product
$apiUrl = http://api.spreadshirt. . self::$shopOptions[shop_source] . /api/v1/shops/ . (string)$item->shop[id] . /products/ . (string)$item->element[id];
$stringXmlShop = wp_remote_get($apiUrl, array(
timeout => 120
));
if (isset($stringXmlShop->errors) && count($stringXmlShop->errors) > 0) die(Error getting articles. Please check Shop-ID, API and secret.);
if ($stringXmlShop[body][0] != <) die($stringXmlShop[body]);
$stringXmlShop = wp_remote_retrieve_body($stringXmlShop);
$objArticles = new SimpleXmlElement($stringXmlShop);
if (!is_object($objArticles)) die(Articles not loaded);
echo ;
} else {
// article
$apiUrl = http://api.spreadshirt. . self::$shopOptions[shop_source] . /api/v1/shops/ . (string)$item->shop[id] . /articles/ . (string)$item->element[id];
$stringXmlShop = wp_remote_get($apiUrl, array(
timeout => 120
));
if (isset($stringXmlShop->errors) && count($stringXmlShop->errors) > 0) die(Error getting articles. Please check Shop-ID, API and secret.);
if ($stringXmlShop[body][0] != <) die($stringXmlShop[body]);
$stringXmlShop = wp_remote_retrieve_body($stringXmlShop);
$objArticles = new SimpleXmlElement($stringXmlShop);
if (!is_object($objArticles)) die(Articles not loaded);
echo ;
}
$priceSum += (float)$item->price->vatIncluded * (int)$item->quantity;
$intSumQuantity += (int)$item->quantity;
}
}
echo
;if (!empty($basketItems)) {
//echo "
".print_r($basketItems)."";foreach ($basketItems->basketItems->basketItem as $item) {
if ((string)$item->element[type] == sprd:product) {
// Product
$apiUrl = http://api.spreadshirt. . self::$shopOptions[shop_source] . /api/v1/shops/ . (string)$item->shop[id] . /products/ . (string)$item->element[id];
$stringXmlShop = wp_remote_get($apiUrl, array(
timeout => 120
));
if (isset($stringXmlShop->errors) && count($stringXmlShop->errors) > 0) die(Error getting articles. Please check Shop-ID, API and secret.);
if ($stringXmlShop[body][0] != <) die($stringXmlShop[body]);
$stringXmlShop = wp_remote_retrieve_body($stringXmlShop);
$objArticles = new SimpleXmlElement($stringXmlShop);
if (!is_object($objArticles)) die(Articles not loaded);
echo
Afbeelding niet beschikbaarDe oorspronkelijke afbeelding of link ontbreekt.
Afbeelding niet beschikbaarDe oorspronkelijke afbeelding of link ontbreekt.
. htmlspecialchars((empty($objArticles->name) ? $item->description : $objArticles->name), ENT_QUOTES) .
. __(Size, $this->stringTextdomain) . : . (string)$item->element->properties->property[0] .
. __(Quantity, $this->stringTextdomain) . : . (int)$item->quantity .
. __(Size, $this->stringTextdomain) . : . (string)$item->element->properties->property[0] .
. __(Quantity, $this->stringTextdomain) . : . (int)$item->quantity .
. self::formatPrice((float)$item->price->vatIncluded * (int)$item->quantity, ) .
} else {
// article
$apiUrl = http://api.spreadshirt. . self::$shopOptions[shop_source] . /api/v1/shops/ . (string)$item->shop[id] . /articles/ . (string)$item->element[id];
$stringXmlShop = wp_remote_get($apiUrl, array(
timeout => 120
));
if (isset($stringXmlShop->errors) && count($stringXmlShop->errors) > 0) die(Error getting articles. Please check Shop-ID, API and secret.);
if ($stringXmlShop[body][0] != <) die($stringXmlShop[body]);
$stringXmlShop = wp_remote_retrieve_body($stringXmlShop);
$objArticles = new SimpleXmlElement($stringXmlShop);
if (!is_object($objArticles)) die(Articles not loaded);
echo
Afbeelding niet beschikbaarDe oorspronkelijke afbeelding of link ontbreekt.
Afbeelding niet beschikbaarDe oorspronkelijke afbeelding of link ontbreekt.
. htmlspecialchars((empty($objArticles->name) ? $item->description : $objArticles->name), ENT_QUOTES) .
. __(Size, $this->stringTextdomain) . : . (string)$item->element->properties->property[0] .
. __(Quantity, $this->stringTextdomain) . : . (int)$item->quantity .
. __(Size, $this->stringTextdomain) . : . (string)$item->element->properties->property[0] .
. __(Quantity, $this->stringTextdomain) . : . (int)$item->quantity .
. self::formatPrice((float)$item->price->vatIncluded * (int)$item->quantity, ) .
}
$priceSum += (float)$item->price->vatIncluded * (int)$item->quantity;
$intSumQuantity += (int)$item->quantity;
}
}
echo
echo
. __(Total (excl. Shipping), $this->stringTextdomain) . . self::formatPrice($priceSum, ) .
;if ($intSumQuantity > 0) {
echo
. __(Proceed to checkout, $this->stringTextdomain) .
;} else {
echo
. __(Proceed to checkout, $this->stringTextdomain) .
;}
}
die();
}
// delete cart
public function doCartItemDelete() {
//if (!wp_verify_nonce($_GET[nonce], spreadplugin)) die(Security check);
$this->reparseShortcodeData();
// create an new basket if not exist
if (isset($_SESSION[basketUrl][self::$shopOptions[shop_source] . self::$shopOptions[shop_language]])) {
// uuid test
if (preg_match(/w{8}-w{4}-w{4}-w{4}-w{12}/, $_POST[id])) {
self:SMILEYYYYYYYYYYYBEGIN:deleteBasketItem($_SESSION[basketUrl][self::$shopOptions[shop_source] . self::$shopOptions[shop_language]], $_POST[id]);
}
}
die();
}
