PHP - Change Position Of The Legal Terms In Woocommerce Checkout Page
Dear forum, I`m always trying hard, but after 5 hours I really need some help in php coding. My problem deals with my checkout page for woocommerce. At the moment, my legal terms are above the total-order-table where u can find the booked product, order-subtotal, order-total and tex-total. But I need to display the legal terms under my total-order table. I need the terms directly above the "Buy now" button. Do you guys know which file to modify ? I tried everything. Nothing worked for me. You will find a picture in this post. There you can see my problem. Would be pretty nice if you can give me some information. Kind regards,
Similar TutorialsHey guys! I need your help with some issues. Firstly, I have an own website with a database filled with products, and also a template page(template.php) for each product. Problem is that I don't know how to generate each product from the database in the template.php file using their id from the database. How can I do this? Second problem, I got an own checkout and I don't know how to redirect the customer to a "thank you for buying" page after clicking "Finish Order". It sends the customer to a white page where it says: "Thanks for buying!". Third and last thing, do you guys know where can I find a php checkout template to follow? Thanks in advance for your answers! Cheers! Not sure if I'm trying to achieve something totally crazy here, or if this is something pretty standard. Didn't have much luck with searching as I'm not fully down with all the terms. (A) I have one site providing an RSS feed. (B) I have one site I want to search, once for each of the items in the feed A. (C) I want the results of the search in (B) to be displayed on page (C). So for example, the feed on (A) says; apples bananas oranges cheese I want site (B) to search for each of those terms (by passing the item in the feed (A) to the ?search= part of the URL of that page) and then show the results from THAT search on page C. Bit of a complex one, let me know if you need me to clarify. Thanks for any help! Hello everyone, I'm simply trying to move a character on a map. When the user selects a direction and a speed the character is moved on the map. Simple right? I've tried a few methods of doing this to no avail. I will list the different things I've tried. Code: [Select] <form action="index.php?do=move" method="post"> <select name="direction"> <option value="north" selected>North</option> <option value="south">South</option> <option value="east">East</option> <option value="west">West</option> </select> <select name="speed"> <option value="move0" selected>Feet +0</option> <option value="move1">Goat +1</option> <option value="move2">Donkey +2</option> <option value="move3">Cow +3</option> <option value="move4">Pig +4</option> <option value="move5">Horse +5</option> </select><br /> <input type="submit" name="post" value="Move"> </form> if (isset($_POST["post"])) { if (isset($_POST["direction"]) == "north") {$latitude++; if ($longitude > $controlrow["gamesize"]) { $latitude = $controlrow["gamesize"]; } } elseif ((isset($_POST["direction"]) == "north") AND (($_POST["speed"]) == "move1")) {$latitude++; if ($latitude > ($controlrow["gamesize"]*2)) { $latitude = ($controlrow["gamesize"]*2); } } elseif ((isset($_POST["direction"]) == "north") AND (($_POST["speed"]) == "move2")) {$latitude++; if ($latitude > ($controlrow["gamesize"]*3)) { $latitude = ($controlrow["gamesize"]*3); } } elseif ((isset($_POST["direction"]) == "north") AND (($_POST["speed"]) == "move3")) {$latitude++; if ($latitude > ($controlrow["gamesize"]*4)) { $latitude = ($controlrow["gamesize"]*4); } } elseif ((isset($_POST["direction"]) == "north") AND (($_POST["speed"]) == "move4")) {$latitude++; if ($latitude > ($controlrow["gamesize"]*5)) { $latitude = ($controlrow["gamesize"]*5); } } elseif ((isset($_POST["direction"]) == "north") AND (($_POST["speed"]) == "move5")) {$latitude++; if ($latitude > ($controlrow["gamesize"]*6)) { $latitude = ($controlrow["gamesize"]*6); } } elseif (isset($_POST["direction"]) == "south") {$latitude--; if ($latitude < ($controlrow["gamesize"]*-1)) { $latitude = ($controlrow["gamesize"]*-1); } } elseif ((isset($_POST["direction"]) == "south") AND (($_POST["speed"]) == "move1")) {$latitude--; if ($latitude < ($controlrow["gamesize"]*-2)) { $latitude = ($controlrow["gamesize"]*-2); } } elseif ((isset($_POST["direction"]) == "south") AND (($_POST["speed"]) == "move2")) {$latitude--; if ($latitude < ($controlrow["gamesize"]*-3)) { $latitude = ($controlrow["gamesize"]*-3); } } elseif ((isset($_POST["direction"]) == "south") AND (($_POST["speed"]) == "move3")) {$latitude--; if ($latitude < ($controlrow["gamesize"]*-4)) { $latitude = ($controlrow["gamesize"]*-4); } } elseif ((isset($_POST["direction"]) == "south") AND (($_POST["speed"]) == "move4")) {$latitude--; if ($latitude < ($controlrow["gamesize"]*-5)) { $latitude = ($controlrow["gamesize"]*-5); } } elseif ((isset($_POST["direction"]) == "south") AND (($_POST["speed"]) == "move5")) {$latitude--; if ($latitude < ($controlrow["gamesize"]*-6)) { $latitude = ($controlrow["gamesize"]*-6); } } elseif (isset($_POST["direction"]) == "east") {$longitude++; if ($longitude > $controlrow["gamesize"]) { $longitude = $controlrow["gamesize"]; } } elseif ((isset($_POST["direction"]) == "east") AND (($_POST["speed"]) == "move1")) {$longitude++; if ($longitude > ($controlrow["gamesize"]*2)) { $longitude = ($controlrow["gamesize"]*2); } } elseif ((isset($_POST["direction"]) == "east") AND (($_POST["speed"]) == "move2")) {$longitude++; if ($longitude > ($controlrow["gamesize"]*3)) { $longitude = ($controlrow["gamesize"]*3); } } elseif ((isset($_POST["direction"]) == "east") AND (($_POST["speed"]) == "move3")) {$longitude++; if ($longitude > ($controlrow["gamesize"]*4)) { $longitude = ($controlrow["gamesize"]*4); } } elseif ((isset($_POST["direction"]) == "east") AND (($_POST["speed"]) == "move4")) {$longitude++; if ($longitude > ($controlrow["gamesize"]*5)) { $longitude = ($controlrow["gamesize"]*5); } } elseif ((isset($_POST["direction"]) == "east") AND (($_POST["speed"]) == "move5")) {$longitude++; if ($longitude > ($controlrow["gamesize"]*6)) { $longitude = ($controlrow["gamesize"]*6); } } elseif (isset($_POST["direction"]) == "west") {$longitude--; if ($longitude < ($controlrow["gamesize"]*-1)) { $longitude = ($controlrow["gamesize"]*-1); } } elseif ((isset($_POST["direction"]) == "west") AND (($_POST["speed"]) == "move1")) {$longitude--; if ($longitude < ($controlrow["gamesize"]*-2)) { $longitude = ($controlrow["gamesize"]*-2); } } elseif ((isset($_POST["direction"]) == "west") AND (($_POST["speed"]) == "move2")) {$longitude--; if ($longitude < ($controlrow["gamesize"]*-3)) { $longitude = ($controlrow["gamesize"]*-3); } } elseif ((isset($_POST["direction"]) == "west") AND (($_POST["speed"]) == "move3")) {$longitude--; if ($longitude < ($controlrow["gamesize"]*-4)) { $longitude = ($controlrow["gamesize"]*-4); } } elseif ((isset($_POST["direction"]) == "west") AND (($_POST["speed"]) == "move4")) {$longitude--; if ($longitude < ($controlrow["gamesize"]*-5)) { $longitude = ($controlrow["gamesize"]*-5); } } elseif ((isset($_POST["direction"]) == "west") AND (($_POST["speed"]) == "move5")) {$longitude--; if ($longitude < ($controlrow["gamesize"]*-6)) { $longitude = ($controlrow["gamesize"]*-6); } } } Also if ((isset($_POST["post"]) == "north") && (isset($_POST["speed"]) == "move0")) { $latitude++; if ($latitude > $controlrow["gamesize"]) { $longitude = $controlrow["gamesize"]; } } else { if ((isset($_POST["post"]) == "north") && (isset($_POST["speed"]) == "move1")) { $latitude++; if ($latitude > ($controlrow["gamesize"]*2)) { $latitude = ($controlrow["gamesize"]*2); } } else { if ((isset($_POST["post"]) == "north") && (isset($_POST["speed"]) == "move2")) { $latitude++; if ($latitude > ($controlrow["gamesize"]*3)) { $latitude = ($controlrow["gamesize"]*3); } } else { if ((isset($_POST["post"]) == "north") && (isset($_POST["speed"]) == "move3")) { $latitude++; if ($latitude > ($controlrow["gamesize"]*4)) { $latitude = ($controlrow["gamesize"]*4); } } else { if ((isset($_POST["post"]) == "north") && (isset($_POST["speed"]) == "move4")) { $latitude++; if ($latitude > ($controlrow["gamesize"]*5)) { $latitude = ($controlrow["gamesize"]*5); } } else { if ((isset($_POST["post"]) == "north") && (isset($_POST["speed"]) == "move5")) { $latitude++; if ($latitude > ($controlrow["gamesize"]*6)) { $latitude = ($controlrow["gamesize"]*6); } } } } } } } Any help would be appreciated. If you need more info just ask. Thanks, Waffles Hello I use this code to display popup login when user to clicked on a "proceed to checkout" button in the cart page (woocomerce) <?php function woocommerce_button_proceed_to_checkout() { $checkout_url = WC()->cart->get_checkout_url(); ?> <div <?php echo mf_get_option( 'login_reg_popup' ) ? 'data-toggle="modal" data-target="#login-modal"' : null; ?>> <a class="checkout-button button alt wc-forward" href="<?php echo ! mf_get_option( 'login_reg_popup' ) ? wc_get_page_permalink( 'myaccount' ) : '#'; ?>" class="checkout-button button alt wc-forward"><?php _e( 'اقدام به پرداخت', 'woocommerce' ); ?></a> <?php }
But after login, I want the user to be redirected to the "checkout" page if it is on the cart page
I found the following code but I couldn't put it in the code above <?php //redirect to your "current" page wp_redirect( $_SERVER["HTTP_REFERER"] ); // redirect to the "checkout" page function wpse_131562_redirect() { if (! is_user_logged_in() && (is_woocommerce() || is_cart()) ) { // feel free to customize the following line to suit your needs wp_redirect(site_url('checkout/')); exit; } } add_action('template_redirect', 'wpse_131562_redirect');
Greetings! I'm a newbie in php programming started with learning wordpress. I'm working on a local machine and trying to modifying a woocommerce order report plugin. The issue i'm facing is this order report plugin shows only 1 product name even though customer ordered multiple products. I want to show all product names. Your help will be much appreciated
<?php // Add the Product Sales Report to the WordPress admin add_action('admin_menu', 'hm_psrf_admin_menu'); function hm_psrf_admin_menu() { add_submenu_page('woocommerce', 'Custom Order Report', 'Custom Order Report', 'view_woocommerce_reports', 'hm_sbpf', 'hm_sbpf_page'); } function hm_psrf_default_report_settings() { return array( 'report_time' => '30d', 'report_start' => date('Y-m-d', current_time('timestamp') - (86400 * 31)), 'report_end' => date('Y-m-d', current_time('timestamp') - 86400), 'order_statuses' => array('wc-processing', 'wc-on-hold', 'wc-completed'), 'products' => 'all', 'product_cats' => array(), 'product_ids' => '', 'variations' => 0, 'orderby' => 'quantity', 'orderdir' => 'desc', 'fields' => array('product_id', 'product_sku', 'product_name', 'quantity_sold', 'gross_sales'), 'limit_on' => 0, 'limit' => 10, 'include_header' => 1, 'exclude_free' => 0 ); } // This function generates the Product Sales Report page HTML function hm_sbpf_page() { $savedReportSettings = get_option('hm_psr_report_settings'); if (isset($_POST['op']) && $_POST['op'] == 'preset-del' && !empty($_POST['r']) && isset($savedReportSettings[$_POST['r']])) { unset($savedReportSettings[$_POST['r']]); update_option('hm_psr_report_settings', $savedReportSettings); $_POST['r'] = 0; echo('<script type="text/javascript">location.href = location.href;</script>'); } $reportSettings = (empty($savedReportSettings) ? hm_psrf_default_report_settings() : array_merge(hm_psrf_default_report_settings(), $savedReportSettings[ isset($_POST['r']) && isset($savedReportSettings[$_POST['r']]) ? $_POST['r'] : 0 ] )); // For backwards compatibility with pre-1.4 versions if (!empty($reportSettings['cat'])) { $reportSettings['products'] = 'cats'; $reportSettings['product_cats'] = array($reportSettings['cat']); } $fieldOptions = array( 'order_id' => 'Order ID', /*'product_id' => 'Product ID',*/ 'customer_name' => 'Customer Name', /*'variation_id' => 'Variation ID',*/ 'city' => 'City', 'address' => 'Address', 'product_name' => 'Product Name', 'quantity_sold' => 'Quantity Sold', /*'product_sku' => 'Product SKU',*/ 'gross_sales' => 'Gross Sales', 'product_categories' => 'Schools', /*'variation_attributes' => 'Variation Attributes',*/ /*'gross_after_discount' => 'Gross Sales (After Discounts)'*/ 'ceremony_date' => 'Ceremony Date', 'ceremony_time' => 'Ceremony Time', 'customer_note' => 'Additional Information', ); include(dirname(__FILE__).'/admin.php'); } // Hook into WordPress init; this function performs report generation when // the admin form is submitted add_action('init', 'hm_sbpf_on_init', 9999); function hm_sbpf_on_init() { global $pagenow; // Check if we are in admin and on the report page if (!is_admin()) return; if ($pagenow == 'admin.php' && isset($_GET['page']) && $_GET['page'] == 'hm_sbpf' && !empty($_POST['hm_sbp_do_export'])) { // Verify the nonce check_admin_referer('hm_sbpf_do_export'); $newSettings = array_intersect_key($_POST, hm_psrf_default_report_settings()); foreach ($newSettings as $key => $value) if (!is_array($value)) $newSettings[$key] = htmlspecialchars($value); // Update the saved report settings $savedReportSettings = get_option('hm_psr_report_settings'); $savedReportSettings[0] = array_merge(hm_psrf_default_report_settings(), $newSettings); update_option('hm_psr_report_settings', $savedReportSettings); // Check if no fields are selected or if not downloading if (empty($_POST['fields']) || empty($_POST['hm_sbp_download'])) return; // Assemble the filename for the report download $filename = 'Product Sales - '; if (!empty($_POST['cat']) && is_numeric($_POST['cat'])) { $cat = get_term($_POST['cat'], 'product_cat'); if (!empty($cat->name)) $filename .= addslashes(html_entity_decode($cat->name)).' - '; } $filename .= date('Y-m-d', current_time('timestamp')).'.csv'; // Send headers header('Content-Type: text/csv'); header('Content-Disposition: attachment; filename="'.$filename.'"'); // Output the report header row (if applicable) and body $stdout = fopen('php://output', 'w'); if (!empty($_POST['include_header'])) hm_sbpf_export_header($stdout); hm_sbpf_export_body($stdout); exit; } } // This function outputs the report header row function hm_sbpf_export_header($dest, $return=false) { $header = array(); foreach ($_POST['fields'] as $field) { switch ($field) { case 'order_id': $header[] = 'Order ID'; break; case 'product_name': $header[] = 'Product Name'; break; case 'quantity_sold': $header[] = 'Quantity Sold'; break; case 'gross_sales': $header[] = 'Gross Sales'; break; case 'product_categories': $header[] = 'Schools'; break; case 'customer_name': $header[] = 'Customer Name'; break; case 'city': $header[] = 'City'; break; case 'address': $header[] = 'Address'; break; case 'ceremony_date': $header[] = 'Ceremony Date'; break; case 'ceremony_time': $header[] = 'Ceremony Time'; break; case 'customer_note': $header[] = 'Additional Information'; break; } } if ($return) return $header; fputcsv($dest, $header); } // This function generates and outputs the report body rows function hm_sbpf_export_body($dest, $return=false) { global $woocommerce, $wpdb; $product_ids = array(); if ($_POST['products'] == 'cats') { $cats = array(); foreach ($_POST['product_cats'] as $cat) if (is_numeric($cat)) $cats[] = $cat; $product_ids = get_objects_in_term($cats, 'product_cat'); } else if ($_POST['products'] == 'ids') { foreach (explode(',', $_POST['product_ids']) as $productId) { $productId = trim($productId); if (is_numeric($productId)) $product_ids[] = $productId; } } // Calculate report start and end dates (timestamps) switch ($_POST['report_time']) { case '0d': $end_date = strtotime('midnight', current_time('timestamp')); $start_date = $end_date; break; case '1d': $end_date = strtotime('midnight', current_time('timestamp')) - 86400; $start_date = $end_date; break; case '7d': $end_date = strtotime('midnight', current_time('timestamp')) - 86400; $start_date = $end_date - (86400 * 6); break; case '1cm': $start_date = strtotime(date('Y-m', current_time('timestamp')).'-01 midnight -1month'); $end_date = strtotime('+1month', $start_date) - 86400; break; case '0cm': $start_date = strtotime(date('Y-m', current_time('timestamp')).'-01 midnight'); $end_date = strtotime('+1month', $start_date) - 86400; break; case '+1cm': $start_date = strtotime(date('Y-m', current_time('timestamp')).'-01 midnight +1month'); $end_date = strtotime('+1month', $start_date) - 86400; break; case '+7d': $start_date = strtotime('midnight', current_time('timestamp')) + 86400; $end_date = $start_date + (86400 * 6); break; case '+30d': $start_date = strtotime('midnight', current_time('timestamp')) + 86400; $end_date = $start_date + (86400 * 29); break; case 'custom': $end_date = strtotime('midnight', strtotime($_POST['report_end'])); $start_date = strtotime('midnight', strtotime($_POST['report_start'])); break; default: // 30 days is the default $end_date = strtotime('midnight', current_time('timestamp')) - 86400; $start_date = $end_date - (86400 * 29); } // Assemble order by string $orderby = (in_array($_POST['orderby'], array('product_id', 'gross', 'gross_after_discount')) ? $_POST['orderby'] : 'quantity'); $orderby .= ' '.($_POST['orderdir'] == 'asc' ? 'ASC' : 'DESC'); // Create a new WC_Admin_Report object include_once($woocommerce->plugin_path().'/includes/admin/reports/class-wc-admin-report.php'); $wc_report = new WC_Admin_Report(); $wc_report->start_date = $start_date; $wc_report->end_date = $end_date; //echo(date('Y-m-d', $end_date)); $where_meta = array(); if ($_POST['products'] != 'all') { $where_meta[] = array( 'type' => 'order_item_meta', 'meta_key' => '_product_id', 'operator' => 'in', 'meta_value' => $product_ids ); } if (!empty($_POST['exclude_free'])) { $where_meta[] = array( 'meta_key' => '_line_total', 'meta_value' => 0, 'operator' => '!=', 'type' => 'order_item_meta' ); } // Get report data // Avoid max join size error $wpdb->query('SET SQL_BIG_SELECTS=1'); // Prevent plugins from overriding the order status filter add_filter('woocommerce_reports_order_statuses', 'hm_psrf_report_order_statuses', 9999); // Based on woocoommerce/includes/admin/reports/class-wc-report-sales-by-product.php $sold_products = $wc_report->get_order_report_data(array( 'data' => array( '_product_id' => array( 'type' => 'order_item_meta', 'order_item_type' => 'line_item', 'function' => '', 'name' => 'product_id' ), '_qty' => array( 'type' => 'order_item_meta', 'order_item_type' => 'line_item', 'function' => 'SUM', 'name' => 'quantity' ), '_line_subtotal' => array( 'type' => 'order_item_meta', 'order_item_type' => 'line_item', 'function' => 'SUM', 'name' => 'gross' ), '_line_total' => array( 'type' => 'order_item_meta', 'order_item_type' => 'line_item', 'function' => 'SUM', 'name' => 'gross_after_discount' ), /*usama*/ 'order_id' => array( 'type' => 'order_item', 'order_item_type' => 'line_item', 'function' => '', 'name' => 'order_id' ) /*usama*/ ), 'query_type' => 'get_results', 'group_by' => 'order_id', 'where_meta' => $where_meta, 'order_by' => $orderby, 'limit' => (!empty($_POST['limit_on']) && is_numeric($_POST['limit']) ? $_POST['limit'] : ''), 'filter_range' => ($_POST['report_time'] != 'all'), 'order_types' => wc_get_order_types('order_count'), 'order_status' => hm_psrf_report_order_statuses() )); // Remove report order statuses filter remove_filter('woocommerce_reports_order_statuses', 'hm_psrf_report_order_statuses', 9999); if ($return) $rows = array(); // Output report rows foreach ($sold_products as $product) { $row = array(); /*usama*/ $order = wc_get_order($product->order_id); $customerName = $order->get_billing_first_name().' '.$order->get_billing_last_name(); $billingCity = $order->get_billing_city(); $billingAddress1 = $order->get_billing_address_1(); $note = $order->get_customer_note(); //echo $product->order_id; //echo $customerName.$city.$billingAddress1; //echo '<pre>';print_r($order);exit; /*usama*/ foreach ($_POST['fields'] as $field) { switch ($field) { case 'order_id': $row[] = $product->order_id; break; case 'product_name': $row[] = html_entity_decode(get_the_title($product->product_id)); break; case 'quantity_sold': $row[] = $product->quantity; break; case 'gross_sales': $row[] = $product->gross; break; /*case 'variation_id': $row[] = (empty($product->variation_id) ? '' : $product->variation_id); break; case 'product_sku': $row[] = get_post_meta($product->product_id, '_sku', true); break;*/ case 'product_categories': $terms = get_the_terms($product->product_id, 'product_cat'); if (empty($terms)) { $row[] = ''; } else { $categories = array(); foreach ($terms as $term) $categories[] = $term->name; $row[] = implode(', ', $categories); } break; case 'customer_name': $row[] = $customerName; break; case 'city': $row[] = $billingCity; break; case 'address': $row[] = $billingAddress1; break; case 'customer_note': $row[] = $note; break; /*case 'gross_after_discount': $row[] = $product->gross_after_discount; break;*/ /*usama*/ case 'ceremony_date': $row[] = $order->get_meta( '_billing_myfield12', true ); break; case 'ceremony_time': $row[] = $order->get_meta( '_billing_myfield13', true ); break; case 'customer_note': $row[] = $order->get_meta( '_billing_myfield14', true ); break; } } if ($return) $rows[] = $row; else fputcsv($dest, $row); } if ($return) return $rows; } add_action('admin_enqueue_scripts', 'hm_psrf_admin_enqueue_scripts'); function hm_psrf_admin_enqueue_scripts() { wp_enqueue_style('hm_psrf_admin_style', plugins_url('css/hm-product-sales-report.css', __FILE__)); wp_enqueue_style('pikaday', plugins_url('css/pikaday.css', __FILE__)); wp_enqueue_script('moment', plugins_url('js/moment.min.js', __FILE__)); wp_enqueue_script('pikaday', plugins_url('js/pikaday.js', __FILE__)); } // Schedulable email report hook add_filter('pp_wc_get_schedulable_email_reports', 'hm_psrf_add_schedulable_email_reports'); function hm_psrf_add_schedulable_email_reports($reports) { $reports['hm_psr'] = array( 'name' => 'Product Sales Report', 'callback' => 'hm_psrf_run_scheduled_report', 'reports' => array( 'last' => 'Last used settings' ) ); return $reports; } function hm_psrf_run_scheduled_report($reportId, $start, $end, $args=array(), $output=false) { $savedReportSettings = get_option('hm_psr_report_settings'); if (!isset($savedReportSettings[0])) return false; $prevPost = $_POST; $_POST = $savedReportSettings[0]; $_POST['report_time'] = 'custom'; $_POST['report_start'] = date('Y-m-d', $start); $_POST['report_end'] = date('Y-m-d', $end); $_POST = array_merge($_POST, array_intersect_key($args, $_POST)); if ($output) { echo('<table><thead><tr>'); foreach (hm_sbpf_export_header(null, true) as $heading) { echo("<th>$heading</th>"); } echo('</tr></thead><tbody>'); foreach (hm_sbpf_export_body(null, true) as $row) { echo('<tr>'); foreach ($row as $cell) echo('<td>'.htmlspecialchars($cell).'</td>'); echo('</tr>'); } echo('</tbody></table>'); $_POST = $prevPost; return; } $filename = get_temp_dir().'/Product Sales Report.csv'; $out = fopen($filename, 'w'); if (!empty($_POST['include_header'])) hm_sbpf_export_header($out); hm_sbpf_export_body($out); fclose($out); $_POST = $prevPost; return $filename; } function hm_psrf_report_order_statuses() { $wcOrderStatuses = wc_get_order_statuses(); $orderStatuses = array(); if (!empty($_POST['order_statuses'])) { foreach ($_POST['order_statuses'] as $orderStatus) { if (isset($wcOrderStatuses[$orderStatus])) $orderStatuses[] = substr($orderStatus, 3); } } return $orderStatuses; } /* Review/donate notice */ register_activation_hook(__FILE__, 'hm_psrf_first_activate'); function hm_psrf_first_activate() { $pre = 'hm_psr'; $firstActivate = get_option($pre.'_first_activate'); if (empty($firstActivate)) { update_option($pre.'_first_activate', time()); } } if (is_admin() && get_option('hm_psr_rd_notice_hidden') != 1 && time() - get_option('hm_psr_first_activate') >= (14*86400)) { add_action('admin_notices', 'hm_psrf_rd_notice'); add_action('wp_ajax_hm_psrf_rd_notice_hide', 'hm_psrf_rd_notice_hide'); } function hm_psrf_rd_notice() { $pre = 'hm_psr'; $slug = 'product-sales-report-for-woocommerce'; echo(' <div id="'.$pre.'_rd_notice" class="updated notice is-dismissible"><p>Do you use the <strong>Product Sales Report</strong> plugin? Please support our free plugin by <a href="" target="_blank">making a donation</a>!product-sales-report-for-woocommerce Thanks!</p></div> <script>jQuery(document).ready(function($){$(\'#'.$pre.'_rd_notice\').on(\'click\', \'.notice-dismiss\', function(){jQuery.post(ajaxurl, {action:\'hm_psrf_rd_notice_hide\'})});});</script> '); } function hm_psrf_rd_notice_hide() { $pre = 'hm_psr'; update_option($pre.'_rd_notice_hidden', 1); } ?>
Hi Everyone
I'm working with the woo commerece plugin and i'd like to have a sub heading under the title of each product.
Style and format is sorted however i want a particular Category to show in the sub heading section. I've managed to get as far as showing all categories but i want to narrow this down to just one category that is under a parent category.
Below is the code i am using, could anyone suggest how i could achieve showing any child category selected under a parent category.
Thanks
<?php /** * Single Product title * * @author WooThemes * @package WooCommerce/Templates * @version 1.6.4 */ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly global $post, $product; $cat_count = sizeof( get_the_terms( $post->ID, 'product_cat' ) ); ?> <h1 itemprop="name" class="product_title entry-title"><?php the_title(); ?></h1> <?php echo $product->get_categories( ', ', '<span class="posted_in">' . _n( 'Artist:', 'Artist:', $cat_count, 'woocommerce' ) . ' ', '.</span>' ); ?> HI,
I have a wordpress site that uses WooCommerce and also WooThemes "Wish list" extension as part of a shop.
I am wanting to hide the "add to cart" button when a price is 0.00 but retain the "Add to Wish List" button.
I have already spoken to WooThemes and there responce is they do not offer coding assistance, i would have to employee someone to look at this for me..
I do have some code that kind of works... in that it does hide the "add to cart" button but it also hides the "add to wish list" button
<?php /* * Swop the 'Free!' price notice and hide the cart with 'Subscription Item' in WooCommerce */ add_filter( 'woocommerce_variable_free_price_html', 'hide_free_price_notice' ); add_filter( 'woocommerce_free_price_html', 'hide_free_price_notice' ); add_filter( 'woocommerce_variation_free_price_html', 'hide_free_price_notice' ); function hide_free_price_notice( $price ) { remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 ); remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 ); return 'Subscription Item'; } ?>I'm no programmer so i have no idea if this is a complex fix or something that maybe you guys on a forum can help out with. If it's out of the scope of general foum help i will have to post a job somewhere to see if i can get some help that way. Many Thanks... Is this the correct way to use IS NOT in an if statement? Code: [Select] if($today<>"$projected") { } Hello, I am trying to make the buy product button on all single product pages to open in a popup iframe or simular! I am new to java, php and such and I am looking for how to achieve this?
I have been researching this for over a month and nothing seems to work. I am affiliated with Amazon so I need my woocommerce buy product buttons to open a new smaller popup window in front of my site!
I have already had it set to open as _blank, But I really need all my external product button links to open as a popup! Is this possible? I have tried editing cart.php and I know nothing about java. Please help!!
Thank you in advance,
Dee
I need to copy a table from one code to another. But I couldn't figure out how to do it properly. Just tried to copy code from one file to another but it doesn't work the same. I need to find where to change the code to show right columns.
https://easyupload.io/maoa9h - zipped cart.php (original code with right table) and review.php (the one that doesn't show right table)
We need to copy the table from cart.php: But it doesn't work. The quantity column doesn't show in review.php - as you can see here https://ibb.co/brP0yy1 I'm trying to show on my order printed receipt some checkout fields and extras from the products. The website is www.prontoitaliano.co.uk/shop What needs to appear on the receipt are all the extras options from all the products(See checkboxes in all pasta dishes and checkboxes toppings in "create your own pizza") and 2 fields from the checkout page (Pick up Date, Pick up Time). To send the order to the printer I'm using the "Star cloud PRNT woocommerce" plugin and for the pickup date and time fields "ultimate woocommerce delivery and pickup date time", I've attached below the code that needs to be edited to add more fields to the receipt. I know that probably it's not difficult to solve my issue but I don't have any knowledge of php and I hope you guys can assist me. Also, I've attached a picture showing what is missing on the printed receipt and what result I'm trying to get. Thanks for your time!
<?php function star_cloudprnt_get_column_separated_data($columns) { $max_chars = STAR_CLOUDPRNT_MAX_CHARACTERS_THREE_INCH; $total_columns = count($columns); if ($total_columns == 0) return ""; if ($total_columns == 1) return $columns[0]; if ($total_columns == 2) { $total_characters = strlen($columns[0])+strlen($columns[1]); $total_whitespace = $max_chars - $total_characters; if ($total_whitespace < 0) return ""; return $columns[0].str_repeat(" ", $total_whitespace).$columns[1]; } $total_characters = 0; foreach ($columns as $column) { $total_characters += strlen($column); } $total_whitespace = $max_chars - $total_characters; if ($total_whitespace < 0) return ""; $total_spaces = $total_columns-1; $space_width = floor($total_whitespace / $total_spaces); $result = $columns[0].str_repeat(" ", $space_width); for ($i = 1; $i < ($total_columns-1); $i++) { $result .= $columns[$i].str_repeat(" ", $space_width); } $result .= $columns[$total_columns-1]; return $result; } function star_cloudprnt_get_seperator() { $max_chars = STAR_CLOUDPRNT_MAX_CHARACTERS_THREE_INCH; return str_repeat('_', $max_chars); } function star_cloudprnt_parse_order_status($status) { if ($status === 'wc-pending') return 'Pending Payment'; else if ($status === 'wc-processing') return 'Processing'; else if ($status === 'wc-on-hold') return 'On Hold'; else if ($status === 'wc-completed') return 'Completed'; else if ($status === 'wc-cancelled') return 'Cancelled'; else if ($status === 'wc-refunded') return 'Refunded'; else if ($status === 'wc-failed') return 'Failed'; else return "Unknown"; } function star_cloudprnt_get_codepage_1252_currency_symbol() { $symbol = get_woocommerce_currency_symbol(); if ($symbol === "£") return "\xA3"; // £ pound else if ($symbol === "$") return "\x24"; // $ dollar else if ($symbol === "€") return "\x80"; // € euro return ""; // return blank by default } function star_cloudprnt_get_formatted_variation($variation, $order, $item_id) { $return = ''; if (is_array($variation)) { $variation_list = array(); foreach ($variation as $name => $value) { // If the value is missing, get the value from the item if (!$value) { $meta_name = esc_attr(str_replace('attribute_', '', $name)); $value = $order->get_item_meta($item_id, $meta_name, true); } // If this is a term slug, get the term's nice name if (taxonomy_exists(esc_attr(str_replace('attribute_', '', $name)))) { $term = get_term_by('slug', $value, esc_attr(str_replace('attribute_', '', $name))); if (!is_wp_error($term) && ! empty($term->name)) { $value = $term->name; } } else { $value = ucwords(str_replace( '-', ' ', $value )); } $variation_list[] = wc_attribute_label(str_replace('attribute_', '', $name)) . ': ' . rawurldecode($value); } $return .= implode('||', $variation_list); } return $return; } function star_cloudprnt_create_receipt_items($order, &$printer) { $order_items = $order->get_items(); foreach ($order_items as $item_id => $item_data) { $product_name = $item_data['name']; $product_id = $item_data['product_id']; $variation_id = $item_data['variation_id']; $item_qty = $order->get_item_meta($item_id, "_qty", true); $item_total_price = floatval($order->get_item_meta($item_id, "_line_total", true)) +floatval($order->get_item_meta($item_id, "_line_tax", true)); $item_price = floatval($item_total_price) / intval($item_qty); $currencyHex = star_cloudprnt_get_codepage_1252_currency_symbol(); $formatted_item_price = number_format($item_price, 2, '.', ''); $formatted_total_price = number_format($item_total_price, 2, '.', ''); $printer->set_text_emphasized(); $printer->add_text_line(str_replace('–', '-', $product_name)." - ID: ".$product_id.""); $printer->cancel_text_emphasized(); if ($variation_id != 0) { $product_variation = new WC_Product_Variation( $variation_id ); $variation_data = $product_variation->get_variation_attributes(); $variation_detail = star_cloudprnt_get_formatted_variation($variation_data, $order, $item_id); $exploded = explode("||", $variation_detail); foreach($exploded as $exploded_variation) { $printer->add_text_line(" ".ucwords($exploded_variation)); } } $printer->add_text_line(star_cloudprnt_get_column_separated_data(array(" Qty: ". $item_qty." x Cost: ".$currencyHex.$formatted_item_price, $currencyHex.$formatted_total_price))); } } function star_cloudprnt_create_address($order, $order_meta, &$printer) { $fname = $order_meta[_shipping_first_name][0]; $lname = $order_meta[_shipping_last_name][0]; $a1 = $order_meta[_shipping_address_1][0]; $a2 = $order_meta[_shipping_address_2][0]; $city = $order_meta[_shipping_city][0]; $state = $order_meta[_shipping_state][0]; $postcode = $order_meta[_shipping_postcode][0]; $tel = $order_meta[_billing_phone][0]; $printer->set_text_emphasized(); if ($a1 == '') { $printer->add_text_line("Billing Address:"); $printer->cancel_text_emphasized(); $fname = $order_meta[_billing_first_name][0]; $lname = $order_meta[_billing_last_name][0]; $a1 = $order_meta[_billing_address_1][0]; $a2 = $order_meta[_billing_address_2][0]; $city = $order_meta[_billing_city][0]; $state = $order_meta[_billing_state][0]; $postcode = $order_meta[_billing_postcode][0]; } else { $printer->add_text_line("Shipping Address:"); $printer->cancel_text_emphasized(); } $printer->add_text_line($fname." ".$lname); $printer->add_text_line($a1); if ($a2 != '') $printer->add_text_line($a2); if ($city != '') $printer->add_text_line($city); if ($state != '') $printer->add_text_line($state); if ($postcode != '') $printer->add_text_line($postcode); $printer->add_text_line("Tel: ".$tel); } function star_cloudprnt_print_order_summary($selectedPrinter, $file, $order_id) { $order = wc_get_order($order_id); $shipping_items = @array_shift($order->get_items('shipping')); $order_meta = get_post_meta($order_id); $printer = new Star_CloudPRNT_Star_Line_Mode_Job($selectedPrinter, $file); $printer->set_codepage("20"); // 20 hex == 32 decimal == 1252 Windows Latin-1 if (get_option('star-cloudprnt-print-logo-top-input')) $printer->add_nv_logo(esc_attr(get_option('star-cloudprnt-print-logo-top-input'))); $printer->set_text_emphasized(); $printer->set_text_center_align(); $printer->add_text_line("ORDER NOTIFICATION"); $printer->set_text_left_align(); $printer->cancel_text_emphasized(); $printer->add_new_line(1); $printer->add_text_line(star_cloudprnt_get_column_separated_data(array("Order #".$order_id, date("d-m-y H:i:s", time())))); $printer->add_new_line(1); $printer->add_text_line("Order Status: ".star_cloudprnt_parse_order_status($order->post->post_status)); $printer->add_text_line("Order Date: ".$order->order_date); if (isset($shipping_items['name'])) { $printer->add_new_line(1); $printer->add_text_line("Shipping Method: ".$shipping_items['name']); } $printer->add_text_line("Payment Method: ".$order_meta[_payment_method_title][0]); $printer->add_new_line(1); $printer->add_text_line(star_cloudprnt_get_column_separated_data(array('ITEM', 'TOTAL'))); $printer->add_text_line(star_cloudprnt_get_seperator()); star_cloudprnt_create_receipt_items($order, $printer); $printer->add_new_line(1); $printer->set_text_right_align(); $formatted_overall_total_price = number_format($order_meta[_order_total][0], 2, '.', ''); $printer->add_text_line("TOTAL ".star_cloudprnt_get_codepage_1252_currency_symbol().$formatted_overall_total_price); $printer->set_text_left_align(); $printer->add_new_line(1); $printer->add_text_line("All prices are inclusive of tax (if applicable)."); $printer->add_new_line(1); star_cloudprnt_create_address($order, $order_meta, $printer); $printer->add_new_line(1); $printer->set_text_emphasized(); $printer->add_text_line("Customer Provided Notes:"); $printer->cancel_text_emphasized(); $printer->add_text(empty($order->post->post_excerpt) ? "None" : $order->post->post_excerpt); if (get_option('star-cloudprnt-print-logo-bottom-input')) $printer->add_nv_logo(esc_attr(get_option('star-cloudprnt-print-logo-bottom-input'))); $printer->printjob(); } function star_cloudprnt_woo_on_thankyou($order_id) { $file = STAR_CLOUDPRNT_PRINTER_PENDING_SAVE_PATH.star_cloudprnt_get_os_path("/order_".$order_id."_".time().".bin"); $selectedPrinter = ""; $printerList = star_cloudprnt_get_printer_list(); if (!empty($printerList)) { foreach ($printerList as $printer) { if (get_option('star-cloudprnt-printer-select') == $printer['name']) { $selectedPrinter = $printer['printerMAC']; break; } } if ($selectedPrinter === "" && count($printerList) === 1) $selectedPrinter = $printer['printerMAC']; if ($selectedPrinter !== "") star_cloudprnt_print_order_summary($selectedPrinter, $file, $order_id); } } function star_cloudprnt_setup_order_handler() { if (selected(get_option('star-cloudprnt-select'), "enable", false) !== "" && star_cloudprnt_is_woo_activated()) { add_action('woocommerce_thankyou', 'star_cloudprnt_woo_on_thankyou', 1, 1); } }
Hi I want to reduce the size of an image. Using Pascal this takes one line of code. However in php so far my research shows me that I need to use a library. (JQuery with a plug-in) Is this normal. To get the real power out of php will I need to use libraries.. I am happy with php. I just need to know how best to use this language.. Thank you.. Here's my thought: A person buys data, they have a quota, I'm talking about cellular networks. In any area, a tower or provider is more prevalent / stronger than others. What if, a person could install an app that allowed them to broadcast / be as a hotspot while getting paid per kb "sold". Technically I am not breaking the law am I? I mean that person 'paid' for that data. What is the difference between selling it to someone for money on their behalf (and mine) as opposed to wasting it on useless activities like browsing social media sites... ?
It would be an app that has both parties, "searching" and "transmitting".
What is "illegal" about this?
Aside from obvious problems like security Hello, I am looking for an event manager that I can put into my site...............I search on google and cant find anything besides for event sites.........does anyone have any suggestion scripts or searches to help me? I'm using a woocommerce order report plugin, some customers order multiple products but order report shows only number of order and one product name: I want to see all product names: also I want to see customer notes it doesn't show up
<?php /** * Plugin Name: Custom Order Report * Description: Generates a report on individual WooCommerce products sold during a specified time period. * Version: 1.4.8 */ // Add the Product Sales Report to the WordPress admin add_action('admin_menu', 'hm_psrf_admin_menu'); function hm_psrf_admin_menu() { add_submenu_page('woocommerce', 'Custom Order Report', 'Custom Order Report', 'view_woocommerce_reports', 'hm_sbpf', 'hm_sbpf_page'); } function hm_psrf_default_report_settings() { return array( 'report_time' => '30d', 'report_start' => date('Y-m-d', current_time('timestamp') - (86400 * 31)), 'report_end' => date('Y-m-d', current_time('timestamp') - 86400), 'order_statuses' => array('wc-processing', 'wc-on-hold', 'wc-completed'), 'products' => 'all', 'product_cats' => array(), 'product_ids' => '', 'variations' => 0, 'orderby' => 'quantity', 'orderdir' => 'desc', 'fields' => array('product_id', 'product_sku', 'product_name', 'quantity_sold', 'gross_sales'), 'limit_on' => 0, 'limit' => 10, 'include_header' => 1, 'exclude_free' => 0 ); } // This function generates the Product Sales Report page HTML function hm_sbpf_page() { $savedReportSettings = get_option('hm_psr_report_settings'); if (isset($_POST['op']) && $_POST['op'] == 'preset-del' && !empty($_POST['r']) && isset($savedReportSettings[$_POST['r']])) { unset($savedReportSettings[$_POST['r']]); update_option('hm_psr_report_settings', $savedReportSettings); $_POST['r'] = 0; echo('<script type="text/javascript">location.href = location.href;</script>'); } $reportSettings = (empty($savedReportSettings) ? hm_psrf_default_report_settings() : array_merge(hm_psrf_default_report_settings(), $savedReportSettings[ isset($_POST['r']) && isset($savedReportSettings[$_POST['r']]) ? $_POST['r'] : 0 ] )); // For backwards compatibility with pre-1.4 versions if (!empty($reportSettings['cat'])) { $reportSettings['products'] = 'cats'; $reportSettings['product_cats'] = array($reportSettings['cat']); } $fieldOptions = array( 'order_id' => 'Order ID', /*'product_id' => 'Product ID',*/ 'customer_name' => 'Customer Name', /*'variation_id' => 'Variation ID',*/ 'city' => 'City', 'address' => 'Address', 'product_name' => 'Product Name', 'quantity_sold' => 'Quantity Sold', /*'product_sku' => 'Product SKU',*/ 'gross_sales' => 'Gross Sales', 'product_categories' => 'Schools', /*'variation_attributes' => 'Variation Attributes',*/ /*'gross_after_discount' => 'Gross Sales (After Discounts)'*/ 'ceremony_date' => 'Ceremony Date', 'ceremony_time' => 'Ceremony Time', ); include(dirname(__FILE__).'/admin.php'); } // Hook into WordPress init; this function performs report generation when // the admin form is submitted add_action('init', 'hm_sbpf_on_init', 9999); function hm_sbpf_on_init() { global $pagenow; // Check if we are in admin and on the report page if (!is_admin()) return; if ($pagenow == 'admin.php' && isset($_GET['page']) && $_GET['page'] == 'hm_sbpf' && !empty($_POST['hm_sbp_do_export'])) { // Verify the nonce check_admin_referer('hm_sbpf_do_export'); $newSettings = array_intersect_key($_POST, hm_psrf_default_report_settings()); foreach ($newSettings as $key => $value) if (!is_array($value)) $newSettings[$key] = htmlspecialchars($value); // Update the saved report settings $savedReportSettings = get_option('hm_psr_report_settings'); $savedReportSettings[0] = array_merge(hm_psrf_default_report_settings(), $newSettings); update_option('hm_psr_report_settings', $savedReportSettings); // Check if no fields are selected or if not downloading if (empty($_POST['fields']) || empty($_POST['hm_sbp_download'])) return; // Assemble the filename for the report download $filename = 'Product Sales - '; if (!empty($_POST['cat']) && is_numeric($_POST['cat'])) { $cat = get_term($_POST['cat'], 'product_cat'); if (!empty($cat->name)) $filename .= addslashes(html_entity_decode($cat->name)).' - '; } $filename .= date('Y-m-d', current_time('timestamp')).'.csv'; // Send headers header('Content-Type: text/csv'); header('Content-Disposition: attachment; filename="'.$filename.'"'); // Output the report header row (if applicable) and body $stdout = fopen('php://output', 'w'); if (!empty($_POST['include_header'])) hm_sbpf_export_header($stdout); hm_sbpf_export_body($stdout); exit; } } // This function outputs the report header row function hm_sbpf_export_header($dest, $return=false) { $header = array(); foreach ($_POST['fields'] as $field) { switch ($field) { case 'order_id': $header[] = 'Order ID'; break; case 'product_name': $header[] = 'Product Name'; break; case 'quantity_sold': $header[] = 'Quantity Sold'; break; case 'gross_sales': $header[] = 'Gross Sales'; break; case 'product_categories': $header[] = 'Schools'; break; case 'customer_name': $header[] = 'Customer Name'; break; case 'city': $header[] = 'City'; break; case 'address': $header[] = 'Address'; break; case 'ceremony_date': $header[] = 'Ceremony Date'; break; case 'ceremony_time': $header[] = 'Ceremony Time'; break; } } if ($return) return $header; fputcsv($dest, $header); } // This function generates and outputs the report body rows function hm_sbpf_export_body($dest, $return=false) { global $woocommerce, $wpdb; $product_ids = array(); if ($_POST['products'] == 'cats') { $cats = array(); foreach ($_POST['product_cats'] as $cat) if (is_numeric($cat)) $cats[] = $cat; $product_ids = get_objects_in_term($cats, 'product_cat'); } else if ($_POST['products'] == 'ids') { foreach (explode(',', $_POST['product_ids']) as $productId) { $productId = trim($productId); if (is_numeric($productId)) $product_ids[] = $productId; } } // Calculate report start and end dates (timestamps) switch ($_POST['report_time']) { case '0d': $end_date = strtotime('midnight', current_time('timestamp')); $start_date = $end_date; break; case '1d': $end_date = strtotime('midnight', current_time('timestamp')) - 86400; $start_date = $end_date; break; case '7d': $end_date = strtotime('midnight', current_time('timestamp')) - 86400; $start_date = $end_date - (86400 * 6); break; case '1cm': $start_date = strtotime(date('Y-m', current_time('timestamp')).'-01 midnight -1month'); $end_date = strtotime('+1month', $start_date) - 86400; break; case '0cm': $start_date = strtotime(date('Y-m', current_time('timestamp')).'-01 midnight'); $end_date = strtotime('+1month', $start_date) - 86400; break; case '+1cm': $start_date = strtotime(date('Y-m', current_time('timestamp')).'-01 midnight +1month'); $end_date = strtotime('+1month', $start_date) - 86400; break; case '+7d': $start_date = strtotime('midnight', current_time('timestamp')) + 86400; $end_date = $start_date + (86400 * 6); break; case '+30d': $start_date = strtotime('midnight', current_time('timestamp')) + 86400; $end_date = $start_date + (86400 * 29); break; case 'custom': $end_date = strtotime('midnight', strtotime($_POST['report_end'])); $start_date = strtotime('midnight', strtotime($_POST['report_start'])); break; default: // 30 days is the default $end_date = strtotime('midnight', current_time('timestamp')) - 86400; $start_date = $end_date - (86400 * 29); } // Assemble order by string $orderby = (in_array($_POST['orderby'], array('product_id', 'gross', 'gross_after_discount')) ? $_POST['orderby'] : 'quantity'); $orderby .= ' '.($_POST['orderdir'] == 'asc' ? 'ASC' : 'DESC'); // Create a new WC_Admin_Report object include_once($woocommerce->plugin_path().'/includes/admin/reports/class-wc-admin-report.php'); $wc_report = new WC_Admin_Report(); $wc_report->start_date = $start_date; $wc_report->end_date = $end_date; //echo(date('Y-m-d', $end_date)); $where_meta = array(); if ($_POST['products'] != 'all') { $where_meta[] = array( 'type' => 'order_item_meta', 'meta_key' => '_product_id', 'operator' => 'in', 'meta_value' => $product_ids ); } if (!empty($_POST['exclude_free'])) { $where_meta[] = array( 'meta_key' => '_line_total', 'meta_value' => 0, 'operator' => '!=', 'type' => 'order_item_meta' ); } // Get report data // Avoid max join size error $wpdb->query('SET SQL_BIG_SELECTS=1'); // Prevent plugins from overriding the order status filter add_filter('woocommerce_reports_order_statuses', 'hm_psrf_report_order_statuses', 9999); // Based on woocoommerce/includes/admin/reports/class-wc-report-sales-by-product.php $sold_products = $wc_report->get_order_report_data(array( 'data' => array( '_product_id' => array( 'type' => 'order_item_meta', 'order_item_type' => 'line_item', 'function' => '', 'name' => 'product_id' ), '_qty' => array( 'type' => 'order_item_meta', 'order_item_type' => 'line_item', 'function' => 'SUM', 'name' => 'quantity' ), '_line_subtotal' => array( 'type' => 'order_item_meta', 'order_item_type' => 'line_item', 'function' => 'SUM', 'name' => 'gross' ), '_line_total' => array( 'type' => 'order_item_meta', 'order_item_type' => 'line_item', 'function' => 'SUM', 'name' => 'gross_after_discount' ), /*usama*/ 'order_id' => array( 'type' => 'order_item', 'order_item_type' => 'line_item', 'function' => '', 'name' => 'order_id' ) /*usama*/ ), 'query_type' => 'get_results', 'group_by' => 'order_id', 'where_meta' => $where_meta, 'order_by' => $orderby, 'limit' => (!empty($_POST['limit_on']) && is_numeric($_POST['limit']) ? $_POST['limit'] : ''), 'filter_range' => ($_POST['report_time'] != 'all'), 'order_types' => wc_get_order_types('order_count'), 'order_status' => hm_psrf_report_order_statuses() )); // Remove report order statuses filter remove_filter('woocommerce_reports_order_statuses', 'hm_psrf_report_order_statuses', 9999); if ($return) $rows = array(); // Output report rows foreach ($sold_products as $product) { $row = array(); /*usama*/ $order = wc_get_order($product->order_id); $customerName = $order->get_billing_first_name().' '.$order->get_billing_last_name(); $billingCity = $order->get_billing_city(); $billingAddress1 = $order->get_billing_address_1(); //echo $product->order_id; //echo $customerName.$city.$billingAddress1; //echo '<pre>';print_r($order);exit; /*usama*/ foreach ($_POST['fields'] as $field) { switch ($field) { case 'order_id': $row[] = $product->order_id; break; case 'product_name': $row[] = html_entity_decode(get_the_title($product->product_id)); break; case 'quantity_sold': $row[] = $product->quantity; break; case 'gross_sales': $row[] = $product->gross; break; /*case 'variation_id': $row[] = (empty($product->variation_id) ? '' : $product->variation_id); break; case 'product_sku': $row[] = get_post_meta($product->product_id, '_sku', true); break;*/ case 'product_categories': $terms = get_the_terms($product->product_id, 'product_cat'); if (empty($terms)) { $row[] = ''; } else { $categories = array(); foreach ($terms as $term) $categories[] = $term->name; $row[] = implode(', ', $categories); } break; case 'customer_name': $row[] = $customerName; break; case 'city': $row[] = $billingCity; break; case 'address': $row[] = $billingAddress1; break; /*case 'gross_after_discount': $row[] = $product->gross_after_discount; break;*/ /*usama*/ case 'ceremony_date': $row[] = $order->get_meta( '_billing_myfield12', true ); break; case 'ceremony_time': $row[] = $order->get_meta( '_billing_myfield13', true ); break; } } if ($return) $rows[] = $row; else fputcsv($dest, $row); } if ($return) return $rows; } add_action('admin_enqueue_scripts', 'hm_psrf_admin_enqueue_scripts'); function hm_psrf_admin_enqueue_scripts() { wp_enqueue_style('hm_psrf_admin_style', plugins_url('css/hm-product-sales-report.css', __FILE__)); wp_enqueue_style('pikaday', plugins_url('css/pikaday.css', __FILE__)); wp_enqueue_script('moment', plugins_url('js/moment.min.js', __FILE__)); wp_enqueue_script('pikaday', plugins_url('js/pikaday.js', __FILE__)); } // Schedulable email report hook add_filter('pp_wc_get_schedulable_email_reports', 'hm_psrf_add_schedulable_email_reports'); function hm_psrf_add_schedulable_email_reports($reports) { $reports['hm_psr'] = array( 'name' => 'Product Sales Report', 'callback' => 'hm_psrf_run_scheduled_report', 'reports' => array( 'last' => 'Last used settings' ) ); return $reports; } function hm_psrf_run_scheduled_report($reportId, $start, $end, $args=array(), $output=false) { $savedReportSettings = get_option('hm_psr_report_settings'); if (!isset($savedReportSettings[0])) return false; $prevPost = $_POST; $_POST = $savedReportSettings[0]; $_POST['report_time'] = 'custom'; $_POST['report_start'] = date('Y-m-d', $start); $_POST['report_end'] = date('Y-m-d', $end); $_POST = array_merge($_POST, array_intersect_key($args, $_POST)); if ($output) { echo('<table><thead><tr>'); foreach (hm_sbpf_export_header(null, true) as $heading) { echo("<th>$heading</th>"); } echo('</tr></thead><tbody>'); foreach (hm_sbpf_export_body(null, true) as $row) { echo('<tr>'); foreach ($row as $cell) echo('<td>'.htmlspecialchars($cell).'</td>'); echo('</tr>'); } echo('</tbody></table>'); $_POST = $prevPost; return; } $filename = get_temp_dir().'/Product Sales Report.csv'; $out = fopen($filename, 'w'); if (!empty($_POST['include_header'])) hm_sbpf_export_header($out); hm_sbpf_export_body($out); fclose($out); $_POST = $prevPost; return $filename; } function hm_psrf_report_order_statuses() { $wcOrderStatuses = wc_get_order_statuses(); $orderStatuses = array(); if (!empty($_POST['order_statuses'])) { foreach ($_POST['order_statuses'] as $orderStatus) { if (isset($wcOrderStatuses[$orderStatus])) $orderStatuses[] = substr($orderStatus, 3); } } return $orderStatuses; } /* Review/donate notice */ register_activation_hook(__FILE__, 'hm_psrf_first_activate'); function hm_psrf_first_activate() { $pre = 'hm_psr'; $firstActivate = get_option($pre.'_first_activate'); if (empty($firstActivate)) { update_option($pre.'_first_activate', time()); } } if (is_admin() && get_option('hm_psr_rd_notice_hidden') != 1 && time() - get_option('hm_psr_first_activate') >= (14*86400)) { add_action('admin_notices', 'hm_psrf_rd_notice'); add_action('wp_ajax_hm_psrf_rd_notice_hide', 'hm_psrf_rd_notice_hide'); } function hm_psrf_rd_notice() { $pre = 'hm_psr'; $slug = 'product-sales-report-for-woocommerce'; echo(' <div id="'.$pre.'_rd_notice" class="updated notice is-dismissible"><p>Do you use the <strong>Product Sales Report</strong> plugin? Please support our free plugin by <a href="" target="_blank">making a donation</a>!product-sales-report-for-woocommerce Thanks!</p></div> <script>jQuery(document).ready(function($){$(\'#'.$pre.'_rd_notice\').on(\'click\', \'.notice-dismiss\', function(){jQuery.post(ajaxurl, {action:\'hm_psrf_rd_notice_hide\'})});});</script> '); } function hm_psrf_rd_notice_hide() { $pre = 'hm_psr'; update_option($pre.'_rd_notice_hidden', 1); } ?>
guys i have a submit button that if(isset($_POST['sub_diplo'])) { $_SESSION['tmp']=$_SESSION['tmp']." counts "; } but tthe button is at the end of the page so when i press the button the page reloads and gose to start! exept that my code working! so is any way to move page to first location?? thanks This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=349588.0 I have finally gotten my registration form to work on my website but i have another question! When for example someone registers at my website and type in the wrong email address, i've set php to give out an error message like "Please enter a valid email address". But that message shows up at the verry top-left corner of my page and makes some objekts move around on my page and you can't click in the <input> fields anymore . How could i make those error messages show up above my registration form at the top of my site and maybe style them with a border and maybe make the text red and so that it doesnt change anything on my page? could i use css for that somehow or what? This is how i show the error messages right now: public function show_errors() { echo "<h3>Errors</h3>"; foreach($this->errors as $key=>$value) echo $value."<br>"; } public function valid_data() { if($this->user_exists()) $this->errors[] = 'Username already taken, choose another one!'; if(empty($this->username)) $this->errors[] = 'Please enter a valid username!'; if(empty($this->first_name)) This is part PHP, part MySQL question, but since I'm more interested in the process-flow, I'll ask here. I am ready to start coding the e-commerce module of my website, which features mostly paid subscriptions.
Do the below steps sound like the correct sequence to do things in...
- Anonymous shopper adds subscription to Shopping Cart - Shopper goes to check out - Shopper completes checkout form which includes setting up the account and entering payment details Now for the important stuff... - System takes Shopping Cart details - which include the PHPSessionID - System creates Member record - System takes Shopping Cart details associated with PHPSessionID and links them to the new Member record - System creates Order and Order Details records - System runs the payment - System hopefully gets back a "success" message from Payment Processor - System activates the Member's account
How does that sound at a high-level?
Really what I'm trying to validate is if I should create the Member record 1st, then create the Order records 2nd, and worry about the payment last. (Originally I was going to run the payment first, but I'm thinking it's better to capture the anonymous shopper's details in a Member record and Order records first, because even if the paymnt fails, you want something to work off of - like reaching out to the person and getting another valid payment.)
Thoughts?
|