Skip to content

Instantly share code, notes, and snippets.

@Magons
Last active April 5, 2019 09:53
Show Gist options
  • Select an option

  • Save Magons/7c4e3ba7e3127c4aac6c3dce441fb2c5 to your computer and use it in GitHub Desktop.

Select an option

Save Magons/7c4e3ba7e3127c4aac6c3dce441fb2c5 to your computer and use it in GitHub Desktop.
Describe steps to integrate

Setup

Steps:

  1. inject makeAnOfferData function in js. settings now in json, can we save them in wordpress db through webhook?
<script>
	var makeAnOfferData = (function() {
		var data = {
			product: null,
			cartProducts: [],
			settings: "{\"id\":16,\"product_exit_offer\":true,\"cart_exit_offer\":true,\"product_button\":true,\"cart_button\":false,\"product_timed_overlay\":true,\"sms_notification\":false,\"cart_timed_overlay\":false,\"link_color\":\"\",\"link_background_color\":\"\",\"phone_number\":\"+66994366378\",\"link_type\":\"\",\"link_name\":\"\",\"trigger_on_page\":3,\"main_heading\":\"Want a better price?\",\"timed_overlay_position\":\"top\",\"popup_timer_delay\":10,\"button_background_color\":\"#2DB7AE\",\"button_font_color\":\"#ffffff\",\"timed_overlay_opacity\":\"0.6\",\"button_text\":\"Make an Offer\",\"timed_overlay_background_color\":\"#2DB7AE\",\"expiration\":0,\"current_theme\":{\"id\":28,\"name\":\"Minimal\",\"created_at\":\"2018-10-26T14:14:22.443Z\",\"updated_at\":\"2018-10-26T14:14:22.443Z\"},\"timed_overlay_font_color\":\"#ffffff\",\"timed_overlay_text\":\"Don't like the price?\",\"skus\":[],\"display_rule_type\":1,\"show_phone_number\":false,\"show_shipping_address\":null,\"timed_overlay_button_text\":\"\",\"show_notes_text\":true,\"header_background_color\":\"\",\"main_heading_font_color\":\"\",\"show_combine_overlay\":false,\"secondary_heading_font_color\":\"\",\"prefetch_offer_popup\":true,\"show_quantity\":false,\"theme_setting\":{\"id\":37,\"user_setting_id\":16,\"theme_id\":28,\"created_at\":\"2019-03-19T13:14:26.357Z\",\"updated_at\":\"2019-03-22T08:31:26.342Z\",\"data\":{\"show_gdpr\":\"true\",\"show_name\":\"false\",\"show_notes\":\"true\",\"show_price\":\"true\",\"use_sidebar\":\"true\",\"show_quantity\":\"false\",\"save_and_continue\":\"Save \\u0026 Keep UP\",\"show_phone_number\":\"false\",\"show_confirm_email\":\"false\",\"show_price_with_tax\":\"false\",\"show_shipping_address\":\"true\",\"submit_button_background_color\":\"#ff8000\"}},\"tags\":[],\"collections\":[],\"bcc_myself\":true,\"change_handler\":\"\",\"reminder_email\":true,\"face\":\"post_onboarding\",\"sender_email\":\"\",\"product_overlay_message\":false,\"cart_overlay_message\":false,\"onboarding_tracking\":{\"id\":27,\"step\":8,\"finished\":\"2019-03-19T13:14:53.000Z\",\"skip\":null,\"setup_after_skip\":null,\"user_setting_id\":16,\"created_at\":\"2019-03-19T13:14:53.842Z\",\"updated_at\":\"2019-03-19T13:14:53.842Z\"},\"show_name\":null}"
		};

		data.product = (function() {
			var mf_featured_image = "<?php echo get_the_post_thumbnail_url($loop->post->ID); ?>";
			var mf_other_image = "";
			return {
				title: "<?= $product->get_data()['name'] ?>",
				price: <?= $product->get_data()['price'] ?>,
				currency: null,
				image: mf_featured_image || mf_other_image,
				variants: [],
				tags: '',
				collections: [],
				url: "<?= get_permalink( $product->ID ); ?>",
				available: true
			}
		})();

		return data;
	})();

</script>
  1. inject our script which load settings and drow the button an popup
<script src="http://makeoffer.com/assets/mf_embed.js?mf_tkn=111"></script>
  • setting probably could be load in hook(action, filter) before load the page
  • scritp also could be load, problaby one part to draw the button and iframe before page is loaded.
  1. Checkout process
  • We can't create link to checkout, but we can use coupons

    couponce has a lot of attributes, which cover our needs

  `date_expires`	string	The date the coupon expires, in the site's timezone.
  `individual_use`	boolean	If true, the coupon can only be used individually. Other applied coupons will be removed from the cart. Default is false.
  `product_ids`	array	List of product IDs the coupon can be used on.
  `usage_limit`	integer	How many times the coupon can be used in total.
  • Option to create link wich go to the cart and add product and coupon automaticly (is this possible?)
  1. Take fee for the order paid.
  1. Refund fee if order will be refund
  • user refund order hook
  1. Plugin installation how works payment strip or pay pall?

Also we have some problems with versions of woocommerce and wordpress, the support a lot of them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment