Skip to content

Instantly share code, notes, and snippets.

@dcooney
Last active January 25, 2024 19:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dcooney/ead2c09892fe6aa42fb79ea642166a28 to your computer and use it in GitHub Desktop.
Save dcooney/ead2c09892fe6aa42fb79ea642166a28 to your computer and use it in GitHub Desktop.
<?php
// File: mr-wc-integrator-plugin/btob/dashboard-b2b-widget.php
//
// Replace line #15 in the `view()` function containing raw HTML.
// <h1>Account Summary</h1>
// with the following PHP hook.
echo wp_kses_post( apply_filters( 'mr_b2b_widget_title', '<h1>Account Summary</h1>' ) );
<?php
// Full file.
namespace mr_wc_integration\btob;
use mr_wc_integration\config\settings\Btob_Options;
class Dashboard_B2b_Widget extends Btob_Abstract implements B2b_Widget_Interface {
public function register_hooks() {
add_action( 'woocommerce_account_dashboard', array( $this, 'view' ) );
}
public function view() {
echo wp_kses_post( apply_filters( 'mr_b2b_widget_title', '<h1>Account Summary</h1>' ) );
?>
<div id="mr_widget_b2b"></div>
<script type="text/javascript">
// <![CDATA[
(function (w, d, s) {
window.MR_B2B_Widget_Config = {
url: '<?php echo Btob_Options::get_widget_url(); ?>',
hash: '<?php echo $this->widget_hash;?>>',
channel: 'modernretail',
platform:'woocommerce',
host: 'https://middleware.modernretail.com',
contact_email:'',
contact_email_hash:'<?php echo $this->get_encrypted_email(); ?>',
logo_url:'',
mainColor:'#036032', // Color scheme
backgroundColor:'#EAFAF0', // Color scheme
linkColor:'#036032', // Color scheme
accountSummary:{
show_page: true,
tab_name: 'Account Summary',
credit_limit:'Credit Limit',
balance:'Balance',
credit_available:'Credit Available',
currency: '$'
},
ordersHistory:{
show_page: true,
tab_name: 'Order History',
page_size: true,
show_total: true,
column_name_number:'order number',
column_name_date:'order date',
column_name_total:'total',
},
payments:{
show_page: true,
tab_name: 'Payments',
page_size: true,
show_total: true,
},
quotes:{
show_page: false,
tab_name: 'Quotes'
}
,
openInvoices:{
show_page: true,
tab_name: 'Open Invoices'
}
,
invoiceHistory:{
show_page: true,
tab_name: 'Invoice History'
}
,
openOrders:{
show_page: true,
tab_name: 'Open Orders'
}
};
var f = d.getElementsByTagName(s)[0],
j = d.createElement(s);
j.async = true;
j.src = window.MR_B2B_Widget_Config.url + "index-bundle.js";
f.parentNode.insertBefore(j, f);
})(window, document, 'script');
// ]]>
</script>
<?php
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment