Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Jeff Balicki
/
st_joseph
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
009eecde
authored
2023-03-13 12:41:13 -0400
by
Jeff Balicki
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
woo
Signed-off-by: Jeff <jeff@gotenzing.com>
1 parent
9959f24a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
52 deletions
wp-content/themes/crlg/inc/woo.php
wp-content/themes/crlg/inc/woo.php
View file @
009eecd
...
...
@@ -3,8 +3,7 @@
add_filter
(
'woocommerce_account_menu_items'
,
'misha_rename_downloads'
);
function
misha_rename_downloads
(
$menu_links
){
// $menu_links[ 'TAB ID HERE' ] = 'NEW TAB NAME HERE';
$menu_links
[
'dashboard'
]
=
'My Account'
;
$menu_links
[
'edit-address'
]
=
'Address'
;
...
...
@@ -64,8 +63,6 @@ add_action( 'woocommerce_created_customer', 'wooc_save_extra_register_fields' );
// ----- validate password match on the registration page
function
registration_errors_validation
(
$reg_errors
,
$sanitized_user_login
,
$user_email
)
{
global
$woocommerce
;
...
...
@@ -146,66 +143,58 @@ function my_remove_cart_product_image() {
add_action
(
'acf/save_post'
,
'create_and_attach_woocommerce_product'
,
1
);
add_action
(
'wp_after_insert_post'
,
'create_and_attach_woocommerce_product'
,
1
);
function
create_and_attach_woocommerce_product
(
$course_id
)
{
if
(
get_post_type
(
$course_id
)
==
'sfwd-courses'
)
{
error_log
(
'create_and_attach_woocommerce_product'
);
// Set the product data
$product_data
=
array
(
'post_title'
=>
get_the_title
(
$course_id
),
'post_type'
=>
'product'
,
'post_status'
=>
'publish'
);
// Insert the product
$product_id
=
wp_insert_post
(
$product_data
);
update_post_meta
(
$course_id
,
'_woocommerce_product'
,
$product_id
);
// Set the product type
wp_set_object_terms
(
$product_id
,
'course'
,
'product_type'
);
wp_set_object_terms
(
$product_id
,
'uncategorized'
,
'product_cat'
);
// Set the related_course
$related_course
=
array
(
$course_id
);
update_post_meta
(
$product_id
,
'_related_course'
,
$related_course
);
// Set the prices
update_post_meta
(
$product_id
,
'_regular_price'
,
$price
);
update_post_meta
(
$product_id
,
'_price'
,
$price
);
update_post_meta
(
$product_id
,
'_role_based_price'
,
$sp
);
}
}
add_action
(
'wp_after_insert_post'
,
'my_wp_after_insert_post'
,
10
,
4
);
function
my_wp_after_insert_post
(
$post_id
,
$post
,
$update
,
$post_before
)
{
if
(
'publish'
!==
$post
->
post_status
||
(
$post_before
&&
'publish'
===
$post_before
->
post_status
)
||
wp_is_post_revision
(
$post_id
))
{
if
(
get_post_type
(
$post_id
)
==
'sfwd-courses'
)
{
error_log
(
'woocommerce_learndash_product'
);
learndash_update_setting
(
$post_id
,
'sfwd-courses_course_price_type'
,
'closed'
);
$product_id
=
get_post_meta
(
$post_id
,
'_woocommerce_product'
,
true
);
learndash_update_setting
(
$post_id
,
'sfwd-courses_certificate'
,
426
);
$post
=
get_post
(
$course_id
);
if
(
!
wp_is_post_autosave
(
$post
)
&&
$post
->
post_status
!==
'auto-draft'
&&
!
wp_is_post_revision
(
$course_id
)
)
{
if
(
get_post_type
(
$course_id
)
==
'sfwd-courses'
)
{
if
(
!
get_post_meta
(
$course_id
,
'_woocommerce_product'
,
true
)){
$product_data
=
array
(
'post_title'
=>
get_the_title
(
$course_id
),
'post_type'
=>
'product'
,
'post_status'
=>
'publish'
);
$product_id
=
wp_insert_post
(
$product_data
);
update_post_meta
(
$course_id
,
'_woocommerce_product'
,
$product_id
);
// Set the product type
wp_set_object_terms
(
$product_id
,
'course'
,
'product_type'
);
wp_set_object_terms
(
$product_id
,
'uncategorized'
,
'product_cat'
);
// Set the related_course
$related_course
=
array
(
$course_id
);
update_post_meta
(
$product_id
,
'_related_course'
,
$related_course
);
}
else
{
$product_id
=
get_post_meta
(
$course_id
,
'_woocommerce_product'
,
true
);
$product_data
=
array
(
'ID'
=>
$product_id
,
'post_title'
=>
get_the_title
(
$course_id
)
);
$product
=
wp_update_post
(
$product_data
);
}
learndash_update_setting
(
$course_id
,
'sfwd-courses_course_price_type'
,
'closed'
);
learndash_update_setting
(
$course_id
,
'sfwd-courses_certificate'
,
426
);
if
(
$product_id
!=
""
){
$courses_custom_button_url
=
learndash_update_setting
(
$
post
_id
,
'sfwd-courses_custom_button_url'
,
get_site_url
()
.
'/cart/?add-to-cart='
.
$product_id
);
$courses_custom_button_url
=
learndash_update_setting
(
$
course
_id
,
'sfwd-courses_custom_button_url'
,
get_site_url
()
.
'/cart/?add-to-cart='
.
$product_id
);
}
$price
=
get_post_meta
(
$
post
_id
,
'program_info_cost_&_dates_0_cost'
,
true
);
$price
=
get_post_meta
(
$
course
_id
,
'program_info_cost_&_dates_0_cost'
,
true
);
if
(
$price
!=
""
){
learndash_update_setting
(
$post_id
,
'sfwd-courses_course_price'
,
$price
);
learndash_update_setting
(
$course_id
,
'sfwd-courses_course_price'
,
$price
);
}
$staff_price
=
get_post_meta
(
$
post
_id
,
'program_info_cost_&_dates_0_cost_staff'
,
true
);
$staff_price
=
get_post_meta
(
$
course
_id
,
'program_info_cost_&_dates_0_cost_staff'
,
true
);
if
(
$staff_price
!=
""
){
$sp
=
array
(
'staff'
=>
array
(
'regular_price'
=>
$staff_price
));
update_post_meta
(
$product_id
,
'_regular_price'
,
$price
);
update_post_meta
(
$product_id
,
'_price'
,
$price
);
update_post_meta
(
$product_id
,
'_role_based_price'
,
$sp
);
}
$sp
=
array
(
'staff'
=>
array
(
'regular_price'
=>
$staff_price
));
update_post_meta
(
$product_id
,
'_regular_price'
,
$price
);
update_post_meta
(
$product_id
,
'_price'
,
$price
);
update_post_meta
(
$product_id
,
'_role_based_price'
,
$sp
);
}
}
}
}
// Redirect to All posts dashboard after post update/publish
function
webroomtech_redirect_to_post_list
()
{
global
$pagenow
;
...
...
Please
register
or
sign in
to post a comment