Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
W
woocommerce_bpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
8
Issues
8
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wordpress
woocommerce_bpd
Commits
d12f360d
Commit
d12f360d
authored
May 19, 2016
by
Franco (nextime) Lanza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for woocommerce-switch-currency
parent
0a2e53c3
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
14 deletions
+21
-14
class-product-addon-cart.php
classes/class-product-addon-cart.php
+14
-11
class-product-addon-display.php
classes/class-product-addon-display.php
+1
-1
product-addons.php
product-addons.php
+4
-0
select.php
templates/addons/select.php
+2
-2
No files found.
classes/class-product-addon-cart.php
View file @
d12f360d
...
...
@@ -54,6 +54,7 @@ class Product_Addon_Cart {
* @return void
*/
public
function
add_cart_item
(
$cart_item
)
{
global
$Product_Addon_Prices
;
// Adjust price if addons are set
if
(
!
empty
(
$cart_item
[
'addons'
]
)
)
{
...
...
@@ -96,15 +97,16 @@ class Product_Addon_Cart {
* @return void
*/
public
function
get_item_data
(
$other_data
,
$cart_item
)
{
global
$Product_Addon_Prices
;
if
(
!
empty
(
$cart_item
[
'addons'
]
)
)
{
foreach
(
$cart_item
[
'addons'
]
as
$addon
)
{
$name
=
$addon
[
'name'
];
if
(
$addon
[
'price'
]
>
0
&&
apply_filters
(
'woocommerce_addons_add_price_to_name'
,
'__return_true'
)
)
$name
.=
' ('
.
woocommerce_price
(
$addon
[
'price'
]
)
.
')'
;
$name
.=
' ('
.
woocommerce_price
(
$Product_Addon_Prices
->
get_current_price
(
$addon
[
'price'
])
)
.
')'
;
$other_data
[]
=
array
(
'name'
=>
$name
,
...
...
@@ -126,7 +128,7 @@ class Product_Addon_Cart {
* @return void
*/
public
function
add_cart_item_data
(
$cart_item_meta
,
$product_id
)
{
global
$woocommerce
;
global
$woocommerce
,
$Product_Addon_Prices
;
$product_addons
=
get_product_addons
(
$product_id
);
...
...
@@ -162,7 +164,7 @@ class Product_Addon_Cart {
$cart_item_meta
[
'addons'
][]
=
array
(
'name'
=>
esc_attr
(
$addon
[
'name'
]
),
'value'
=>
esc_attr
(
$option
[
'label'
]
),
'price'
=>
esc_attr
(
$option
[
'price'
]
)
'price'
=>
esc_attr
(
get_current_price
(
$option
[
'price'
])
)
);
}
}
...
...
@@ -202,6 +204,7 @@ class Product_Addon_Cart {
'price'
=>
esc_attr
(
$chosen_option
[
'price'
]
)
);
break
;
case
"custom"
:
case
"custom_textarea"
:
...
...
@@ -225,7 +228,7 @@ class Product_Addon_Cart {
if
(
$addon
[
'type'
]
==
"custom_price"
)
{
$price
=
floatval
(
woocommerce_clean
(
$posted
)
);
//$price = $Product_Addon_Prices->get_current_price($price);
if
(
$price
>=
0
)
{
$cart_item_meta
[
'addons'
][]
=
array
(
'name'
=>
esc_attr
(
$label
),
...
...
@@ -370,7 +373,7 @@ class Product_Addon_Cart {
if
(
$addon
[
'type'
]
==
"custom_price"
)
{
$price
=
floatval
(
woocommerce_clean
(
$posted
)
);
//$price = $Product_Addon_Prices->get_current_price($price);
if
(
$price
<
0
)
{
$this
->
add_error
(
sprintf
(
__
(
'Invalid price entered for "%s".'
,
'woocommerce'
),
$addon
[
'name'
]
)
);
return
false
;
...
...
@@ -587,7 +590,7 @@ class Product_Addon_Cart {
if
(
$addon
[
'type'
]
==
"custom_price"
)
{
$price
=
floatval
(
woocommerce_clean
(
$posted
)
);
$price
=
$price
;
if
(
$price
>=
0
)
{
$cart_item_meta
[
'addons'
][]
=
array
(
'name'
=>
esc_attr
(
$label
),
...
...
classes/class-product-addon-display.php
View file @
d12f360d
...
...
@@ -169,7 +169,7 @@ class Product_Addon_Display {
*/
function
totals
(
$post_id
)
{
global
$product
;
global
$product
,
$Product_Addon_Prices
;
if
(
!
isset
(
$product
)
||
$product
->
id
!=
$post_id
)
$the_product
=
get_product
(
$post_id
);
...
...
product-addons.php
View file @
d12f360d
...
...
@@ -50,6 +50,10 @@ if ( is_woocommerce_active() ) {
include_once
(
'classes/class-product-addon-cart.php'
);
$GLOBALS
[
'Product_Addon_Cart'
]
=
new
Product_Addon_Cart
();
include_once
(
'classes/class-product-addon-prices.php'
);
$GLOBALS
[
'Product_Addon_Prices'
]
=
new
Product_Addon_Prices
();
}
/**
...
...
templates/addons/select.php
View file @
d12f360d
...
...
@@ -8,9 +8,9 @@ $current_value = isset( $_POST['addon-' . sanitize_title( $addon['field-name'] )
<?php
foreach
(
$addon
[
'options'
]
as
$option
)
:
$loop
++
;
$price
=
$option
[
'price'
]
>
0
?
' ('
.
woocommerce_price
(
$option
[
'price'
]
)
.
')'
:
''
;
$price
=
$option
[
'price'
]
>
0
?
' ('
.
woocommerce_price
(
$GLOBALS
[
'Product_Addon_Prices'
]
->
get_current_price
(
$option
[
'price'
])
)
.
')'
:
''
;
?>
<option
data-price=
"
<?php
echo
$
option
[
'price'
]
;
?>
"
value=
"
<?php
echo
sanitize_title
(
$option
[
'label'
]
)
.
'-'
.
$loop
;
?>
"
<?php
selected
(
$current_value
,
sanitize_title
(
$option
[
'label'
]
)
.
'-'
.
$loop
);
?>
>
<?php
echo
wptexturize
(
$option
[
'label'
]
)
.
$price
?>
</option>
<option
data-price=
"
<?php
echo
$
GLOBALS
[
'Product_Addon_Prices'
]
->
get_current_price
(
$option
[
'price'
])
;
?>
"
value=
"
<?php
echo
sanitize_title
(
$option
[
'label'
]
)
.
'-'
.
$loop
;
?>
"
<?php
selected
(
$current_value
,
sanitize_title
(
$option
[
'label'
]
)
.
'-'
.
$loop
);
?>
>
<?php
echo
wptexturize
(
$option
[
'label'
]
)
.
$price
?>
</option>
<?php
endforeach
;
?>
</select>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment